|
30 | 30 | class DataFrameValueCounts(DataFrameOperand, DataFrameOperandMixin): |
31 | 31 | _op_type_ = opcodes.VALUE_COUNTS |
32 | 32 |
|
33 | | - _input = KeyField("input") |
34 | | - _normalize = BoolField("normalize") |
35 | | - _sort = BoolField("sort") |
36 | | - _ascending = BoolField("ascending") |
37 | | - _bins = Int64Field("bins") |
38 | | - _dropna = BoolField("dropna") |
39 | | - _method = StringField("method") |
40 | | - _convert_index_to_interval = BoolField("convert_index_to_interval") |
41 | | - _nrows = Int64Field("nrows") |
42 | | - |
43 | | - def __init__( |
44 | | - self, |
45 | | - normalize=None, |
46 | | - sort=None, |
47 | | - ascending=None, |
48 | | - bins=None, |
49 | | - dropna=None, |
50 | | - method=None, |
51 | | - convert_index_to_interval=None, |
52 | | - nrows=None, |
53 | | - **kw |
54 | | - ): |
55 | | - super().__init__( |
56 | | - _normalize=normalize, |
57 | | - _sort=sort, |
58 | | - _ascending=ascending, |
59 | | - _bins=bins, |
60 | | - _dropna=dropna, |
61 | | - _method=method, |
62 | | - _convert_index_to_interval=convert_index_to_interval, |
63 | | - _nrows=nrows, |
64 | | - **kw |
65 | | - ) |
| 33 | + input = KeyField("input") |
| 34 | + normalize = BoolField("normalize") |
| 35 | + sort = BoolField("sort") |
| 36 | + ascending = BoolField("ascending") |
| 37 | + bins = Int64Field("bins") |
| 38 | + dropna = BoolField("dropna") |
| 39 | + method = StringField("method") |
| 40 | + convert_index_to_interval = BoolField("convert_index_to_interval", default=None) |
| 41 | + nrows = Int64Field("nrows", default=None) |
| 42 | + |
| 43 | + def __init__(self, **kw): |
| 44 | + super().__init__(**kw) |
66 | 45 | self.output_types = [OutputType.series] |
67 | 46 |
|
68 | | - @property |
69 | | - def input(self): |
70 | | - return self._input |
71 | | - |
72 | | - @property |
73 | | - def normalize(self): |
74 | | - return self._normalize |
75 | | - |
76 | | - @property |
77 | | - def sort(self): |
78 | | - return self._sort |
79 | | - |
80 | | - @property |
81 | | - def ascending(self): |
82 | | - return self._ascending |
83 | | - |
84 | | - @property |
85 | | - def bins(self): |
86 | | - return self._bins |
87 | | - |
88 | | - @property |
89 | | - def dropna(self): |
90 | | - return self._dropna |
91 | | - |
92 | | - @property |
93 | | - def method(self): |
94 | | - return self._method |
95 | | - |
96 | | - @property |
97 | | - def convert_index_to_interval(self): |
98 | | - return self._convert_index_to_interval |
99 | | - |
100 | | - @property |
101 | | - def nrows(self): |
102 | | - return self._nrows |
103 | | - |
104 | 47 | def _set_inputs(self, inputs): |
105 | 48 | super()._set_inputs(inputs) |
106 | | - self._input = self._inputs[0] |
| 49 | + self.input = self._inputs[0] |
107 | 50 |
|
108 | 51 | def __call__(self, inp): |
109 | 52 | test_series = build_series(inp).value_counts(normalize=self.normalize) |
110 | | - if self._bins is not None: |
| 53 | + if self.bins is not None: |
111 | 54 | from .cut import cut |
112 | 55 |
|
113 | 56 | # cut |
114 | 57 | try: |
115 | | - inp = cut(inp, self._bins, include_lowest=True) |
| 58 | + inp = cut(inp, self.bins, include_lowest=True) |
116 | 59 | except TypeError: # pragma: no cover |
117 | 60 | raise TypeError("bins argument only works with numeric data.") |
118 | 61 |
|
119 | | - self._bins = None |
120 | | - self._convert_index_to_interval = True |
| 62 | + self.bins = None |
| 63 | + self.convert_index_to_interval = True |
121 | 64 | return self.new_series( |
122 | 65 | [inp], |
123 | 66 | shape=(np.nan,), |
@@ -174,7 +117,7 @@ def tile(cls, op: "DataFrameValueCounts"): |
174 | 117 |
|
175 | 118 | if op.nrows: |
176 | 119 | # set to sort_values |
177 | | - inp.op._nrows = op.nrows |
| 120 | + inp.op.nrows = op.nrows |
178 | 121 | elif op.nrows: |
179 | 122 | inp = inp.iloc[: op.nrows] |
180 | 123 |
|
|
0 commit comments