-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Concat with axis rows #14416
Concat with axis rows #14416
Conversation
Adding tests for concat string axis names Fixing pep8 related spacing
Edit: Didn't realize you already knew this/it was just weirdness with the repo |
Thanks for the tip @paul-mannino ! I'll do that next time. |
Current coverage is 85.26% (diff: 100%)@@ master #14416 diff @@
==========================================
Files 140 140
Lines 50634 50642 +8
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43173 43181 +8
Misses 7461 7461
Partials 0 0
|
@@ -1411,6 +1412,10 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None, | |||
sample = objs[0] | |||
self.objs = objs | |||
|
|||
# Check for string axis parameter | |||
if isinstance(axis, str): |
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 check for string is not needed, this is already handled inside get_axis_number, so you can just do axis = get_axis_number(axis)
---------- | ||
axis : str | ||
Only values 'index', 'columns', or 'rows' will return a value. Other | ||
values will raise a ValueError exception |
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.
This is not fully correct, as the function also checks for integers
@@ -238,3 +238,39 @@ def to_numeric(arg, errors='raise', downcast=None): | |||
return values[0] | |||
else: | |||
return values | |||
|
|||
|
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.
this is not the right place for this at all. remove all of this added code from tools/util (and the tests)
In [2]: pd.DataFrame()._get_axis_number(1)
Out[2]: 1
In [3]: pd.DataFrame()._get_axis_number('index')
Out[3]: 0
In [4]: pd.DataFrame()._get_axis_number('columns')
Out[4]: 1
In [5]: pd.DataFrame()._get_axis_number(1)
Out[5]: 1
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 for this. Just to make sure I understand everything, this is better than the original solution, because it doesn't depend upon the object passed to concat
yet still uses the DataFrame
method without having to reproduce it (and add unnecessary duplication)? And there isn't any problem with creating an empty DataFrame
instance in order to use the method because we can consistently create it every time?
This is my first PR to Pandas, so I appreciate the help!
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.
no that is all fine.
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.
Okay thanks. I believed I've fixed it now.
24eb09d
to
49442be
Compare
Actually, just using the |
Looks good to me |
thanks! |
closes pandas-dev#14369 Author: Brandon M. Burroughs <[email protected]> Closes pandas-dev#14416 from brandonmburroughs/concat_with_axis_rows and squashes the following commits: 9aa260d [Brandon M. Burroughs] Changing axis handling to depend on object passed 49442be [Brandon M. Burroughs] Using dataframe _get_axis_number instance method 64702fb [Brandon M. Burroughs] Updating documentation for concat fdd5260 [Brandon M. Burroughs] Removing duplicate expected dfs 3f08b07 [Brandon M. Burroughs] Adding concat tests for axis 0, 1, and 'index' cf3f998 [Brandon M. Burroughs] Adding ValueError test for concat Series axis 'columns' a6694b9 [Brandon M. Burroughs] Updating documentation 584ebd2 [Brandon M. Burroughs] BUG: Allow concat to take string axis names
closes #14369 Author: Brandon M. Burroughs <[email protected]> Closes #14416 from brandonmburroughs/concat_with_axis_rows and squashes the following commits: 9aa260d [Brandon M. Burroughs] Changing axis handling to depend on object passed 49442be [Brandon M. Burroughs] Using dataframe _get_axis_number instance method 64702fb [Brandon M. Burroughs] Updating documentation for concat fdd5260 [Brandon M. Burroughs] Removing duplicate expected dfs 3f08b07 [Brandon M. Burroughs] Adding concat tests for axis 0, 1, and 'index' cf3f998 [Brandon M. Burroughs] Adding ValueError test for concat Series axis 'columns' a6694b9 [Brandon M. Burroughs] Updating documentation 584ebd2 [Brandon M. Burroughs] BUG: Allow concat to take string axis names (cherry picked from commit fd3be00)
git diff upstream/master | flake8 --diff
I closed #14389 and opened with one in hopes of the new commits showing up.