将行追加到pandas DataFrame而不创建新副本 [英] Append rows to a pandas DataFrame without making a new copy

查看:166
本文介绍了将行追加到pandas DataFrame而不创建新副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

熊猫文档包含注释:

请注意,与list.append方法不同,后者会追加到原始列表,但不返回任何内容,而append不会修改df1并返回添加了df2的副本.

Note Unlike list.append method, which appends to the original list and returns nothing, append here does not modify df1 and returns its copy with df2 appended.

如何在不复制的情况下附加到现有DataFrame?还是按照注释的方式,如何通过附加df2来修改df1而​​什么也不返回?

How can I append to an existing DataFrame without making a copy? Or in the terms of the note how can I modify df1 in place by appending df2 and return nothing?

推荐答案

请参见即将发布的熊猫0.13版本将允许通过loc在不存在的索引数据上添加行.

Upcoming pandas 0.13 version will allow to add rows through loc on non existing index data.

说明位于此处这个新功能称为放大设置.

Description is here and this new feature is called Setting With Enlargement.

这篇关于将行追加到pandas DataFrame而不创建新副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆