-
Notifications
You must be signed in to change notification settings - Fork 44
Pandas 1 fixes #268
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
Pandas 1 fixes #268
Conversation
Please see these links for the rational if interested: pandas-dev/pandas#13443 pandas-dev/pandas#23752
This makes it easier to see what's going on below with the values returned by this function.
This prevents attempting to drop columns that don't exist in merged.columns after setting the index, while still dropping columns that are present in merged.columns. Attempting to do so raises an exception in pandas >= 1. Please see pandas-dev/pandas#8594 for details.
| # Removes the column name used to set the index of `merged` above | ||
| col_diff = set(columns) - set([column]) | ||
| if col_diff: | ||
| counts.drop(col_diff, axis=1, inplace=True, level=0) |
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.
The first kwarg taken by DataFrame.drop is labels and it accepts a single label or list-like. Passing the set directly seems to work fine here, but we can make it a pd.Index or list if that is preferable.
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.
nah, this looks good to me
This avoids attempting to drop columns that had already been dropped in previous calls to _reindex_with_metadata in the for loop in `alpha_rarefaction`. Co-authored-by: Matthew Dillon <[email protected]>
| counts = merged.count() | ||
| counts.drop(columns, axis=1, inplace=True, level=0) | ||
| median_ = merged.median() | ||
| reindexed = merged.set_index(column) |
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.
Avoid mutating merged by assigning to a new DataFrame reindexed.
nbokulich
left a comment
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.
Thanks @andrewsanchez ! please see my inline comment.
|
Thanks for clarifying... LGTM |
No description provided.