conftest.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import numpy as np
  2. import pytest
  3. from pandas import (
  4. DataFrame,
  5. Index,
  6. MultiIndex,
  7. Series,
  8. date_range,
  9. )
  10. @pytest.fixture
  11. def series_ints():
  12. return Series(np.random.rand(4), index=np.arange(0, 8, 2))
  13. @pytest.fixture
  14. def frame_ints():
  15. return DataFrame(
  16. np.random.randn(4, 4), index=np.arange(0, 8, 2), columns=np.arange(0, 12, 3)
  17. )
  18. @pytest.fixture
  19. def series_uints():
  20. return Series(np.random.rand(4), index=Index(np.arange(0, 8, 2, dtype=np.uint64)))
  21. @pytest.fixture
  22. def frame_uints():
  23. return DataFrame(
  24. np.random.randn(4, 4),
  25. index=Index(range(0, 8, 2), dtype=np.uint64),
  26. columns=Index(range(0, 12, 3), dtype=np.uint64),
  27. )
  28. @pytest.fixture
  29. def series_labels():
  30. return Series(np.random.randn(4), index=list("abcd"))
  31. @pytest.fixture
  32. def frame_labels():
  33. return DataFrame(np.random.randn(4, 4), index=list("abcd"), columns=list("ABCD"))
  34. @pytest.fixture
  35. def series_ts():
  36. return Series(np.random.randn(4), index=date_range("20130101", periods=4))
  37. @pytest.fixture
  38. def frame_ts():
  39. return DataFrame(np.random.randn(4, 4), index=date_range("20130101", periods=4))
  40. @pytest.fixture
  41. def series_floats():
  42. return Series(np.random.rand(4), index=Index(range(0, 8, 2), dtype=np.float64))
  43. @pytest.fixture
  44. def frame_floats():
  45. return DataFrame(
  46. np.random.randn(4, 4),
  47. index=Index(range(0, 8, 2), dtype=np.float64),
  48. columns=Index(range(0, 12, 3), dtype=np.float64),
  49. )
  50. @pytest.fixture
  51. def series_mixed():
  52. return Series(np.random.randn(4), index=[2, 4, "null", 8])
  53. @pytest.fixture
  54. def frame_mixed():
  55. return DataFrame(np.random.randn(4, 4), index=[2, 4, "null", 8])
  56. @pytest.fixture
  57. def frame_empty():
  58. return DataFrame()
  59. @pytest.fixture
  60. def series_empty():
  61. return Series(dtype=object)
  62. @pytest.fixture
  63. def frame_multi():
  64. return DataFrame(
  65. np.random.randn(4, 4),
  66. index=MultiIndex.from_product([[1, 2], [3, 4]]),
  67. columns=MultiIndex.from_product([[5, 6], [7, 8]]),
  68. )
  69. @pytest.fixture
  70. def series_multi():
  71. return Series(np.random.rand(4), index=MultiIndex.from_product([[1, 2], [3, 4]]))