Search code examples
pythonpandasreplacerowgoogle-colaboratory

Replace df data with other df data


I'm generating some counts with this code:

df1 = (df.loc[df['Are you okay?']== 'No', 'Are yu sad?']
     .value_counts()
     .rename_axis('Vals')
     .reset_index(name='Count'))

So I'm obtaining the Yes and No Counts, but this is for 3 diferent columns and the only count that I need is Yes this is what I got:

    Vals    Count
0   Yes 0.544
1   No  0.456

But I have this:

enter image description here

And I want to have something like this:

    Vals    Count
0   Yes     0.544
1   Yes(1)  0.032
2   Yes(2)  0.384

Solution

  • df_all_rows = pd.concat([df1, df2, df3], ignore_index=True)