dimanche 1 juillet 2018

I want to populate value in Dataframe based on matching values in other Dataframe

I have one dataframe given as follows:

df1:

col1    col2
------------
VG       12
G        11
A        10
P        06
VP       0
VG       53
A        50

I want the new dataframe such as:

VG    G   A   P   VP
---------------------
12    11  10   06  0
53    0   50   0   0     

I tried achieving this using if condition and I got following error:

Code:

 if df1.Score=='VG':
    df2['VG']=df1.loc[df1['col1'] == 'VG', 'col2']

 The truth value of a Series is ambiguous. Use a.empty, a.bool(), 
 a.item(), a.any() or a.all() 

Aucun commentaire:

Enregistrer un commentaire