所以我必须做这个箱形图,我想限制数据集中某一列的变量,但我遇到的问题是我不知道怎么做。this is what I have for now,我想选择列中排名前十的国家,但我不知道怎么做。
发布于 2020-07-25 11:05:11
如果我正确理解了您的问题,这应该适用于具有名为Nationality的"Nationality“列的名为df的数据帧
import collections
counts = collections.Counter(df.Nationality)
top10countries = [elem for elem, _ in counts.most_common(10)]
df_top10 = df[df['Nationality'].isin(top10countries)]然后使用df_top10制作箱形图。
https://stackoverflow.com/questions/63045429
复制相似问题