Question : check dictionary values pandas dataframe colu
Answered by : daniel-otembo
reverse_dct = {}
for k,v in dct.items(): for i in v: reverse_dct[i] = k
df = pd.DataFrame({'text_column':text_column})
df['word_type'] = df['text_column'].explode().map(reverse_dct).dropna().groupby(level=0).apply(','.join)
Source : https://stackoverflow.com/questions/70580165/how-to-search-list-of-dictionary-values-with-pandas-dataframe-series-column-elem | Last Update : Sun, 13 Feb 22
Question : check if value in dictionary keys python dataframe
Answered by : daniel-otembo
df.Team.replace(d,inplace=True)
df
Out[176]: Market Status Team
0 Chicago 1 [email protected]
1 Chicago 1 [email protected]
2 SFBay 3 [email protected]
3 SFBay 1 [email protected]
4 SFBay 1 [email protected]
Source : https://stackoverflow.com/questions/48693785/check-if-value-is-present-in-dataframe-and-find-it-within-a-dictionary | Last Update : Sun, 13 Feb 22