conftest.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import numpy as np
  2. import pytest
  3. from pandas import DataFrame, MultiIndex
  4. from pandas.util import testing as tm
  5. @pytest.fixture
  6. def mframe():
  7. index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'], ['one', 'two',
  8. 'three']],
  9. codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3],
  10. [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
  11. names=['first', 'second'])
  12. return DataFrame(np.random.randn(10, 3), index=index,
  13. columns=['A', 'B', 'C'])
  14. @pytest.fixture
  15. def df():
  16. return DataFrame(
  17. {'A': ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'],
  18. 'B': ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'],
  19. 'C': np.random.randn(8),
  20. 'D': np.random.randn(8)})
  21. @pytest.fixture
  22. def ts():
  23. return tm.makeTimeSeries()
  24. @pytest.fixture
  25. def seriesd():
  26. return tm.getSeriesData()
  27. @pytest.fixture
  28. def tsd():
  29. return tm.getTimeSeriesData()
  30. @pytest.fixture
  31. def frame(seriesd):
  32. return DataFrame(seriesd)
  33. @pytest.fixture
  34. def tsframe(tsd):
  35. return DataFrame(tsd)
  36. @pytest.fixture
  37. def df_mixed_floats():
  38. return DataFrame({'A': ['foo', 'bar', 'foo', 'bar',
  39. 'foo', 'bar', 'foo', 'foo'],
  40. 'B': ['one', 'one', 'two', 'three',
  41. 'two', 'two', 'one', 'three'],
  42. 'C': np.random.randn(8),
  43. 'D': np.array(
  44. np.random.randn(8), dtype='float32')})
  45. @pytest.fixture
  46. def three_group():
  47. return DataFrame({'A': ['foo', 'foo', 'foo',
  48. 'foo', 'bar', 'bar',
  49. 'bar', 'bar',
  50. 'foo', 'foo', 'foo'],
  51. 'B': ['one', 'one', 'one',
  52. 'two', 'one', 'one', 'one', 'two',
  53. 'two', 'two', 'one'],
  54. 'C': ['dull', 'dull', 'shiny',
  55. 'dull', 'dull', 'shiny', 'shiny',
  56. 'dull', 'shiny', 'shiny', 'shiny'],
  57. 'D': np.random.randn(11),
  58. 'E': np.random.randn(11),
  59. 'F': np.random.randn(11)})