Reputation: 3350
I have this code to extract one row into string, but would like to make it in more time efficient way:
d= dfb_all[ dfb_all.uuid == x["uuid"] ].iloc[0,:].tolist()
d= d.join('_')
is there any alternatives ?
EDIT : The base problem is to map some rows from dataframe dfb_all into dataframe df1 using uuid as column key
is there any efficient to do key mapping between 2 dataframes in pandas ?
Upvotes: 2
Views: 2090
Reputation: 3350
From PiRSquared answer, this is corrected and turn to be faster:
i = (dfb_all.uuid.values == x['uuid']).argmax()
'_'.join(dfb_all.iloc[i, :].values.astype(str).tolist())
Upvotes: 0
Reputation: 294506
Try:
i = (dfb_all.uuid.values == x['uuid']).argmax()
d = '_'.join(dfb_all.values[i].astype(str).values.tolist())
I think. Hard to tell when you didn't provide sample data.
Upvotes: 1