alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

【810】pandas的DataFrame的append方法详细介绍

参考:pandas的DataFrame的append方法详细介绍


官方说明:pandas.DataFrame.append

DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=False)

  Append rows of other to the end of caller, returning a new object.

  Columns in other that are not in the caller are added as new columns.

  Parameters
other: DataFrame or Series/dict-like object, or list of these

The data to append.

ignore_index: bool, default False

If True, the resulting axis will be labeled 0, 1, …, n - 1.

verify_integrity: bool, default False

If True, raise ValueError on creating index with duplicates.

sort: bool, default False

Sort columns if the columns of self and other are not aligned.

Changed in version 1.0.0: Changed to not sort by default.

  Returns: DataFrame

A new DataFrame consisting of the rows of caller and the rows of other.


append 添加字典

import pandas as pd
data = pd.DataFrame() # 生成空dataframe
a = {"x":1, "y":2} # 新建字典,包含列名和数值
data = data.append(a,ignore_index=True) # 注意需要赋值操作
print(data)

显示效果:

 

posted on   McDelfino  阅读(139)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-03-09 【530】MT | 相关 Python 技巧
2012-03-09 【018】Visual Studio 2010 调试总结
2012-03-09 【017】◀▶ C#学习(九) - ADO.NET
2012-03-09 【016】VS2010连接内置SQL数据库
2012-03-09 【015】SQL Server 2008不能连接
点击右上角即可分享
微信分享提示