我正试图通过使用熊猫的国家来获得一组最流行的名字。如代码片段所示,我已经完成了一半,但我不清楚如何将groupedByCountry转换为排序表。你知道吗
import math
import pandas
csv = pandas.read_csv("./name_country.csv.gz", compression="gzip")
data = csv[["name",'country']]
filtered = roleIni[data.country.notnull()]
groupedByCountry = filtered.groupby("country")
您可以使用groupby^{} ,然后使用^{} :
不过,在列上直接^{} ,然后选择^{} (
head(n)
将获得前n名最受欢迎的国家)可能更有效:相关问题 更多 >
编程相关推荐