2
One solution is to create a filter using list comprehension:
filtro=[k[-3:]=='BRL' for k in df.A]
df=df[filtro]
Example with fictitious database:
import pandas as pd
import random
df=pd.DataFrame({"A":["BTC-BRL", "ETH-USD","WAVES-USD","ADA-BRL"]*5, "B":[random.choice(range(5)) for k in range(20)]})
print(df)
Bench before:
A B
0 BTC-BRL 3
1 ETH-USD 1
2 WAVES-USD 2
3 ADA-BRL 1
4 BTC-BRL 3
5 ETH-USD 2
6 WAVES-USD 2
7 ADA-BRL 0
8 BTC-BRL 4
9 ETH-USD 0
10 WAVES-USD 4
11 ADA-BRL 0
12 BTC-BRL 4
13 ETH-USD 1
14 WAVES-USD 0
15 ADA-BRL 4
16 BTC-BRL 1
17 ETH-USD 1
18 WAVES-USD 4
19 ADA-BRL 1
Applying the filter:
filtro=[k[-3:]=='BRL' for k in df.A]
df=df[filtro]
print(df)
Returns:
A B
0 BTC-BRL 3
3 ADA-BRL 1
4 BTC-BRL 3
7 ADA-BRL 0
8 BTC-BRL 4
11 ADA-BRL 0
12 BTC-BRL 4
15 ADA-BRL 4
16 BTC-BRL 1
19 ADA-BRL 1
It was exactly this solution that I was looking for. Thank you very much.
– Nascin