Skip to content
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

Conversation

brandonmburroughs
Copy link
Contributor

I closed #14389 and opened with one in hopes of the new commits showing up.

@paul-mannino
Copy link
Contributor

paul-mannino commented Oct 13, 2016

Edit: Didn't realize you already knew this/it was just weirdness with the repo

@brandonmburroughs
Copy link
Contributor Author

Thanks for the tip @paul-mannino ! I'll do that next time.

@codecov-io
Copy link

codecov-io commented Oct 13, 2016

Current coverage is 85.26% (diff: 100%)

Merging #14416 into master will increase coverage by <.01%

@@             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          

Powered by Codecov. Last update 7d40f18...9aa260d

@@ -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):
Copy link
Member

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
Copy link
Member

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

@jorisvandenbossche jorisvandenbossche added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Oct 13, 2016
@jorisvandenbossche jorisvandenbossche added this to the 0.19.1 milestone Oct 13, 2016
@@ -238,3 +238,39 @@ def to_numeric(arg, errors='raise', downcast=None):
return values[0]
else:
return values


Copy link
Contributor

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

Copy link
Contributor Author

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!

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@brandonmburroughs
Copy link
Contributor Author

Actually, just using the DataFrame _get_axis_number causes tests with Panels to fail. I've updated it to use the DataFrame method if a Series is passed and to use the object itself (sample) otherwise.

@jorisvandenbossche
Copy link
Member

Looks good to me

@jreback jreback closed this in fd3be00 Oct 15, 2016
@jreback
Copy link
Contributor

jreback commented Oct 15, 2016

thanks!

tworec pushed a commit to RTBHOUSE/pandas that referenced this pull request Oct 21, 2016
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
jorisvandenbossche pushed a commit that referenced this pull request Nov 1, 2016
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

concat with axis='rows'
5 participants