这张来自维基百科的表格显示了10大票房。我似乎无法得到“全球总量”一栏的总数。有人能帮忙吗?多谢各位
import pandas as pd
boxoffice_df=pd.read_html('https://en.wikipedia.org/wiki/List_of_highest-grossing_films')
films = boxoffice_df[1]
films.rename(columns = {'Worldwide gross(2020 $)':'worldwide_gross'}, inplace = True)
films.worldwide_gross.sum(axis=0)
您只需使用
regex
在列中保留数字,然后使用series.astype('float')
将列转换为浮点加:
完整代码:
或者先转换数据类型
相关问题 更多 >
编程相关推荐