Python中文
首页
教程
问答
标签
搜索
登录
注册
对Python数据帧中的列求和
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>这张来自维基百科的表格显示了10大票房。我似乎无法得到“全球总量”一栏的总数。有人能帮忙吗?多谢各位</p> <pre><code>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) </code></pre> <p><a href="https://i.stack.imgur.com/n4yRt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n4yRt.png" alt="enter image description here"/></a></p> <p>这是我在计算全球总收益时得到的结果: <a href="https://i.stack.imgur.com/i4wSc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i4wSc.png" alt="enter image description here"/></a></p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<pre><code>Total =films['worldwide_gross'].astype('Int32').sum() </code></pre> <p>或者先转换数据类型</p> <pre><code>films = films.convert_dtypes() Total = films['worldwide_gross'].sum() </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
6 回答
如何在python中从数据帧列表中删除引号
2 回答
如何在python中从数据帧创建列表
6 回答
如何在Python中从数据帧创建嵌套的JSON
2 回答
如何在Python中从数据帧显示wordcloud
3 回答
如何在Python中从数据帧的时间戳中删除字符
3 回答
如何在Python中从数据帧绘制简单绘图?
6 回答
如何在python中从数据帧行提取具有特定长度的范围?
8 回答
如何在python中从数据帧设置dict中的值
9 回答
如何在Python中从数据库中获得一个结果
5 回答
如何在python中从数据框中绘制分类条形图
7 回答
如何在Python中从数据框中选择特定细节?
3 回答
如何在python中从数据集中删除unicode
9 回答
如何在python中从数据集中删除某些数值?
9 回答
如何在python中从数据集中选择行
10 回答
如何在Python中从数组中删除元素
5 回答
如何在python中从数组中删除单个倒逗号?
5 回答
如何在python中从数组中删除对象?
8 回答
如何在python中从数组中删除引号
5 回答
如何在python中从数组中删除所有最小值
10 回答