~teamproject/sisepeu/main

« back to all changes in this revision

Viewing changes to env/lib/python3.6/site-packages/pandas/tests/groupby/conftest.py

  • Committer: riveramarlon113 at gmail
  • Date: 2023-06-04 02:19:28 UTC
  • Revision ID: riveramarlon113@gmail.com-20230604021928-rbt05g3480tfhxxj
Correcion de cosas pequeñas

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import numpy as np
2
 
import pytest
3
 
 
4
 
from pandas import DataFrame, MultiIndex
5
 
import pandas._testing as tm
6
 
from pandas.core.groupby.base import reduction_kernels, transformation_kernels
7
 
 
8
 
 
9
 
@pytest.fixture
10
 
def mframe():
11
 
    index = MultiIndex(
12
 
        levels=[["foo", "bar", "baz", "qux"], ["one", "two", "three"]],
13
 
        codes=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], [0, 1, 2, 0, 1, 1, 2, 0, 1, 2]],
14
 
        names=["first", "second"],
15
 
    )
16
 
    return DataFrame(np.random.randn(10, 3), index=index, columns=["A", "B", "C"])
17
 
 
18
 
 
19
 
@pytest.fixture
20
 
def df():
21
 
    return DataFrame(
22
 
        {
23
 
            "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
24
 
            "B": ["one", "one", "two", "three", "two", "two", "one", "three"],
25
 
            "C": np.random.randn(8),
26
 
            "D": np.random.randn(8),
27
 
        }
28
 
    )
29
 
 
30
 
 
31
 
@pytest.fixture
32
 
def ts():
33
 
    return tm.makeTimeSeries()
34
 
 
35
 
 
36
 
@pytest.fixture
37
 
def tsd():
38
 
    return tm.getTimeSeriesData()
39
 
 
40
 
 
41
 
@pytest.fixture
42
 
def tsframe(tsd):
43
 
    return DataFrame(tsd)
44
 
 
45
 
 
46
 
@pytest.fixture
47
 
def df_mixed_floats():
48
 
    return DataFrame(
49
 
        {
50
 
            "A": ["foo", "bar", "foo", "bar", "foo", "bar", "foo", "foo"],
51
 
            "B": ["one", "one", "two", "three", "two", "two", "one", "three"],
52
 
            "C": np.random.randn(8),
53
 
            "D": np.array(np.random.randn(8), dtype="float32"),
54
 
        }
55
 
    )
56
 
 
57
 
 
58
 
@pytest.fixture
59
 
def three_group():
60
 
    return DataFrame(
61
 
        {
62
 
            "A": [
63
 
                "foo",
64
 
                "foo",
65
 
                "foo",
66
 
                "foo",
67
 
                "bar",
68
 
                "bar",
69
 
                "bar",
70
 
                "bar",
71
 
                "foo",
72
 
                "foo",
73
 
                "foo",
74
 
            ],
75
 
            "B": [
76
 
                "one",
77
 
                "one",
78
 
                "one",
79
 
                "two",
80
 
                "one",
81
 
                "one",
82
 
                "one",
83
 
                "two",
84
 
                "two",
85
 
                "two",
86
 
                "one",
87
 
            ],
88
 
            "C": [
89
 
                "dull",
90
 
                "dull",
91
 
                "shiny",
92
 
                "dull",
93
 
                "dull",
94
 
                "shiny",
95
 
                "shiny",
96
 
                "dull",
97
 
                "shiny",
98
 
                "shiny",
99
 
                "shiny",
100
 
            ],
101
 
            "D": np.random.randn(11),
102
 
            "E": np.random.randn(11),
103
 
            "F": np.random.randn(11),
104
 
        }
105
 
    )
106
 
 
107
 
 
108
 
@pytest.fixture(params=sorted(reduction_kernels))
109
 
def reduction_func(request):
110
 
    """
111
 
    yields the string names of all groupby reduction functions, one at a time.
112
 
    """
113
 
    return request.param
114
 
 
115
 
 
116
 
@pytest.fixture(params=sorted(transformation_kernels))
117
 
def transformation_func(request):
118
 
    """yields the string names of all groupby transformation functions."""
119
 
    return request.param
120
 
 
121
 
 
122
 
@pytest.fixture(params=sorted(reduction_kernels) + sorted(transformation_kernels))
123
 
def groupby_func(request):
124
 
    """yields both aggregation and transformation functions."""
125
 
    return request.param
126
 
 
127
 
 
128
 
@pytest.fixture(params=[True, False])
129
 
def parallel(request):
130
 
    """parallel keyword argument for numba.jit"""
131
 
    return request.param
132
 
 
133
 
 
134
 
@pytest.fixture(params=[True, False])
135
 
def nogil(request):
136
 
    """nogil keyword argument for numba.jit"""
137
 
    return request.param
138
 
 
139
 
 
140
 
@pytest.fixture(params=[True, False])
141
 
def nopython(request):
142
 
    """nopython keyword argument for numba.jit"""
143
 
    return request.param