Issue
I have a data frame:
>df_idbank.dtypes
DATASET object
IDBANK object
KEY object
FREQ object
INDICATEUR object
CORRECTION_label_en object
Etc.
I have another data frame:
>df_INDICATORS
Label IDBANK
0 Summary indicator of overall economic situatio... 1586891
1 Business climate summary indicator - SA series 1586890
2 Trend of expected activity - Overall - SA series 1586916
3 Trend of expected activity - Building structur... 1586885
4 Trend of expected activity - Finishings - SA s... 1586886
This would give a set of values pertaining to only values matching IDBANK =="001586891"
from df_idbank
data frame.
df_idbank = df_idbank.loc[(df_idbank.FREQ == "M") & (df_idbank.CORRECTION_label_en == "Seasonal adjusted") & (df_idbank.IDBANK =="001586891") ]
How do I select all the values matching IDBANK
column in df_INDICATORS
?
Solution
You can use .isin()
:
df_idbank = df_idbank.loc[
(df_idbank.FREQ == "M") &
(df_idbank.CORRECTION_label_en == "Seasonal adjusted") &
(df_idbank.IDBANK.isin(df_INDICATORS.IDBANK)) ]
Answered By - Kirill Kondratenko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.