从熊猫中的特定索引开始,总和行在一起
你好,我的数据框有11行,我正在尝试完成,所以第四行是第4至11行的总和 sum
我试图将数据帧分为2分,总和下半年,将所需的行从通缉的行中删除第一个,然后将两个半与concat合并,但似乎不起作用。 这是一个示例代码:
drop_piv_rank=pivot_rank_famille.drop([4,5,6,7,8,9,10,11], axis=0)
frames_rank=[drop_piv_rank, pivot_rank_famille_grande]
pivot_rank_famille_regroup= pd.concat(frames_rank)
pivot_rank_famille_regroup.head()
这是它给我的输出: 我的代码输出
我不是潘达的专家有人可以帮忙。
Hello my data frame has 11 rows and I'm trying to make it so the 4th row is the sum of row 4 to 11
sum
I tried to seperate the dataframe in 2, sum the second half ,drop the wanted rows from the first and then merge the two half together with concat but is doesn't seem to work.
Here's a sample code:
drop_piv_rank=pivot_rank_famille.drop([4,5,6,7,8,9,10,11], axis=0)
frames_rank=[drop_piv_rank, pivot_rank_famille_grande]
pivot_rank_famille_regroup= pd.concat(frames_rank)
pivot_rank_famille_regroup.head()
Here is the output it gives me :
what my code outputs
I'm not an expert in Pandas so I'd really appreciate it if someone could help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
那应该解决这个问题。我相信第4行表示3,因为索引从0开始
That should do the trick. I believe row 4 means 3 since the index starts at 0