2

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 ?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

dataframe are just string or int values
0

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())

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.