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' #14369

Closed
AlbertDeFusco opened this issue Oct 6, 2016 · 3 comments
Closed

concat with axis='rows' #14369

AlbertDeFusco opened this issue Oct 6, 2016 · 3 comments
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@AlbertDeFusco
Copy link

A small, complete example of the issue

Is there something special going on here that pd.concat seems to interpret axis='rows' as axis=1?

In [1]: import pandas as pd

In [2]: pd.__version__
Out[2]: '0.19.0'

In [3]: import numpy as np

In [5]: df1 = pd.DataFrame({'A':np.random.normal(size=5)}, index=range(5))

In [6]: df2 = pd.DataFrame({'A':np.random.normal(size=5)}, index=range(5))

In [7]: pd.concat([df1,df2], axis=0)
Out[7]: 
          A
0  1.302686
1 -0.463573
2  0.057750
3  0.908621
4 -0.637590
0 -1.876701
1  0.946551
2 -1.696579
3  0.793796
4  1.403455

In [8]: pd.concat([df1,df2], axis='rows')
Out[8]: 
          A         A
0  1.302686 -1.876701
1 -0.463573  0.946551
2  0.057750 -1.696579
3  0.908621  0.793796
4 -0.637590  1.403455

Expected Output

I would think that axis='rows' and axis=0 do the same thing.

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.19.0
nose: None
pip: 8.1.2
setuptools: 27.2.0
Cython: None
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Difficulty Novice labels Oct 6, 2016
@jreback jreback added this to the Next Major Release milestone Oct 6, 2016
@jorisvandenbossche
Copy link
Member

It seems that the conversion from 'rows'/'columns' to 0/1 does not happen in concat, so any string will be evaluated as True in a boolean check ..

@kaushlakers
Copy link

@jreback I use pandas pretty extensively in most of my projects. I'd like to make some contributions back. 😃 Mind if I take a stab at this?

@jreback
Copy link
Contributor

jreback commented Oct 10, 2016

sure the more the merrier

@jreback jreback modified the milestones: 0.19.1, Next Major Release Oct 15, 2016
tworec pushed a commit to RTBHOUSE/pandas that referenced this issue Oct 21, 2016
closes pandas-dev#14369

Author: Brandon M. Burroughs <brandonmburroughs@gmail.com>

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 issue Nov 1, 2016
closes #14369

Author: Brandon M. Burroughs <brandonmburroughs@gmail.com>

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
4 participants