PythonDataScienceHandbook icon indicating copy to clipboard operation
PythonDataScienceHandbook copied to clipboard

03.06 Concatenation - wrong axis argument

Open SRSteinkamp opened this issue 5 years ago • 1 comments

Dear all,

I am greatly appreciating the book so far. I run into the following error in chapter 03.06 with using pd.concat: df3 = make_df('AB', [0, 1]) df4 = make_df('CD', [0, 1]) display('df3', 'df4', "pd.concat([df3, df4], axis='col')")

ValueError: No axis named col for object type <class 'pandas.core.frame.DataFrame'>

In the pandas documentation the axis argument should be 'columns' instead of 'col':

axis : {0/'index', 1/'columns'}, default 0 The axis to concatenate along

Currently I'm not sure if this error is due to me using a later pandas version (I'm using 0.23.4) and whether this should be fixed. If a change is appreciated, I'm happy to create a pull-request!

Best, Simon

SRSteinkamp avatar Jul 10 '19 10:07 SRSteinkamp

since 0.19 version, the axis argument should be 'columns' instead of 'col'

axis : {0/’index’, 1/’columns’}, default 0 The axis to concatenate along

https://pandas.pydata.org/pandas-docs/version/0.19/generated/pandas.concat.html?highlight=concat#pandas.concat

while in 0.18 version, or earlier, something different in the document, which may be the prove for your problem.

axis : {0, 1, ...}, default 0 The axis to concatenate along

https://pandas.pydata.org/pandas-docs/version/0.18/generated/pandas.concat.html?highlight=concat#pandas.concat

Sean16SYSU avatar Oct 11 '19 07:10 Sean16SYSU