Use DataFrame.filter
with DataFrame.stack
and Series.value_counts
:
s = df.filter(like='Language').stack().value_counts()
This is an alternative way
df['lang1'].value_counts() + df['lang2'].value_counts() + df['lang3'].value_counts()
or
cols = ['lang1', 'lang2', 'lang2']
sum([df[col].value_counts() for col in cols])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.