python - Iterating through a Dataframe to get values based on another Dataframe -


lets have following dataframes:

dataframe 1

    cfop    vendas 0   5101    venda 1   6101    venda 2   6107    venda 3   6118    venda 4   6109    venda 

dataframe 2

    name    cfop    vendas 0   john    5101    10,00 1   lea     7008    20,00 2   anthony 6107    15,00 3   frank   7000    17,00 4   tom     6109    21,00 

i want make third dataframe if row 1 of dataframe 1 mathces row 2 dataframe 2.

so, final answer should be:

    name    cfop    vendas 0   john    5101    10,00 2   anthony 6107    15,00 4   tom     6109    21,00 

i stuck, code know wrong:

vendas_somente = []  row in df_entrada:     if df_entrada['cfo'] in df_venda['cfop']:         vendas_somente.append(row)  vendas_somente(10) 

tks

you can create inner merge

in[38]: d1[['cfop']].merge(d2,how='inner',on='cfop') out[38]:      cfop     name vendas 0  5101     john  10,00 1  6107  anthony  15,00 2  6109      tom  21,00 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -