I have been exploring the titanic dataset. I am trying to create a
dataframe which will have the ages of the people who survived the titanic sinking, and those who didn't, in two separate columns.
train = pd.read_csv('train.csv')
test = pd.read_csv('test.csv')
whole = pd.concat([train, test])
df = pd.DataFrame({'survived': whole['Age'][whole['Survived'] == 1],
'died': whole['Age'][whole['Survived'] == 0]})
But I am getting this error
pandas.indexes.base.InvalidIndexError: Reindexing only valid with uniquely valued Index objects
What am I doing wrong?
whole = pd.concat([train, test])towhole = pd.concat([train, test]).reset_index(drop=True)0.19.2Upgrading to0.20.1did not work for me.