-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: fix all flake8 warnings in pandas/tools #12082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,14 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean', | |
---------- | ||
data : DataFrame | ||
values : column to aggregate, optional | ||
index : a column, Grouper, array which has the same length as data, or list of them. | ||
Keys to group by on the pivot table index. | ||
If an array is passed, it is being used as the same manner as column values. | ||
columns : a column, Grouper, array which has the same length as data, or list of them. | ||
Keys to group by on the pivot table column. | ||
If an array is passed, it is being used as the same manner as column values. | ||
index : a column, Grouper, array which has the same length as data, or list | ||
of them. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is another numpydoc problem ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, maybe just shorten it a bit? (maybe 'array which has the same length' -> 'array of same length' is enough to keep within line limit?) But if this happens more, we should maybe look if we can solve this in the numpydoc parser There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the original versions contained commingled types and descriptions. Let me do a proper job fixing |
||
Keys to group by on the pivot table index. If an array is passed, it | ||
is being used as the same manner as column values. | ||
columns : a column, Grouper, array which has the same length as data, or | ||
list of them. | ||
Keys to group by on the pivot table column. If an array is passed, it | ||
is being used as the same manner as column values. | ||
aggfunc : function, default numpy.mean, or list of functions | ||
If list of functions passed, the resulting pivot table will have | ||
hierarchical columns whose top level are the function names (inferred | ||
|
@@ -78,7 +80,8 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean', | |
pieces = [] | ||
keys = [] | ||
for func in aggfunc: | ||
table = pivot_table(data, values=values, index=index, columns=columns, | ||
table = pivot_table(data, values=values, index=index, | ||
columns=columns, | ||
fill_value=fill_value, aggfunc=func, | ||
margins=margins) | ||
pieces.append(table) | ||
|
@@ -124,7 +127,7 @@ def pivot_table(data, values=None, index=None, columns=None, aggfunc='mean', | |
m = MultiIndex.from_arrays(cartesian_product(table.index.levels)) | ||
table = table.reindex_axis(m, axis=0) | ||
except AttributeError: | ||
pass # it's a single level | ||
pass # it's a single level | ||
|
||
try: | ||
m = MultiIndex.from_arrays(cartesian_product(table.columns.levels)) | ||
|
@@ -197,7 +200,7 @@ def _add_margins(table, data, values, rows, cols, aggfunc, | |
result, margin_keys, row_margin = marginal_result_set | ||
else: | ||
marginal_result_set = _generate_marginal_results_without_values( | ||
table, data, rows, cols, aggfunc, margins_name) | ||
table, data, rows, cols, aggfunc, margins_name) | ||
if not isinstance(marginal_result_set, tuple): | ||
return marginal_result_set | ||
result, margin_keys, row_margin = marginal_result_set | ||
|
@@ -273,7 +276,8 @@ def _all_key(key): | |
except TypeError: | ||
|
||
# we cannot reshape, so coerce the axis | ||
piece.set_axis(cat_axis, piece._get_axis(cat_axis)._to_safe_for_reshape()) | ||
piece.set_axis(cat_axis, piece._get_axis( | ||
cat_axis)._to_safe_for_reshape()) | ||
piece[all_key] = margin[key] | ||
|
||
table_pieces.append(piece) | ||
|
@@ -349,13 +353,15 @@ def _all_key(): | |
def _convert_by(by): | ||
if by is None: | ||
by = [] | ||
elif (np.isscalar(by) or isinstance(by, (np.ndarray, Index, Series, Grouper)) | ||
elif (np.isscalar(by) or isinstance(by, (np.ndarray, Index, | ||
Series, Grouper)) | ||
or hasattr(by, '__call__')): | ||
by = [by] | ||
else: | ||
by = list(by) | ||
return by | ||
|
||
|
||
def crosstab(index, columns, values=None, rownames=None, colnames=None, | ||
aggfunc=None, margins=False, dropna=True): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally find this formatting very hard to read (though not real sure what's better)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of these formatting issues stem from statements that are too dense.
result[self.indicator_name]
should be a temporary variable here, as should perhaps the list of new categories