0
I have a dataframe df_currency and need to insert new column based on comparison with another dataframe df_quotation.
Below I have dataframe only with the names of coins:
df_moeda=pd.DataFrame({"Moeda":["BTC", "ETH","WAVES","ADA"]})
Dataframe df_currency:
Moeda
0 BTC
1 ETH
2 WAVES
3 ADA
Below the dataframe with the quotation of the pairs currency:
df_cotacao=pd.DataFrame({"Pares":["ETH-BRL", "ADA-BRL","BTC-BRL","WAVES-BRL"], "Cotação":["12", "34", "56", "78"]})
Dataframe df_quotation:
Pares Cotação
0 ETH-BRL 12
1 ADA-BRL 34
2 BTC-BRL 56
3 WAVES-BRL 78
As a result, I want to add a column in the dataframe df_currency inserting the corresponding currency count.
- Note: Both dataframes do not have the same coin sequence.
The dataframe df_currency should look like this:
Moeda Cotação
0 BTC 56
1 ETH 12
2 WAVES 78
3 ADA 34
This answers your question? How to fill a column of a DF Pandas using, as a comparison, a specific column between this and another DF?
– Lucas
Create a column called currency in df_quotation base with the first 3 letters of the even column. Then merge with df_currency base.
– Lucas