Reputation: 2797
Can someone explain what is wrong with this pandas concat code, and why data frame remains empty ?I am using anaconda distibution, and as far as I remember it was working before.
Upvotes: 16
Views: 22541
Reputation: 55448
You want to use this form:
result = pd.concat([dataframe, series], axis=1)
The pd.concat(...)
doesn't happen "inplace" into the original dataframe
but it would return the concatenated result so you'll want to assign the concatenation somewhere, e.g.:
>>> import pandas as pd
>>> s = pd.Series([1,2,3])
>>> df = pd.DataFrame()
>>> df = pd.concat([df, s], axis=1) # We assign the result back into df
>>> df
0
0 1
1 2
2 3
Upvotes: 20