新聞中心
介紹了這么多關(guān)于Pandas拼接的方法,那你知道如果想要拼接拼接一個(gè)或者多個(gè),還可以追加serise到原來(lái)的dataframe里面如何操作嗎?其實(shí)還是很簡(jiǎn)單的,使用append函數(shù)就可以解決。本文介紹pandas中使用合并append函數(shù)的相關(guān)介紹。

1、使用語(yǔ)法
append(self, other, ignore_index=False, verify_integrity=False)
2、使用參數(shù)
other:另一個(gè)df;
ignore_index:若為T(mén)rue,則對(duì)index進(jìn)行重排;
verify_integrity:對(duì)index的唯一性進(jìn)行驗(yàn)證,若有重復(fù),報(bào)錯(cuò)。若已經(jīng)設(shè)置了ignore_index,則該參數(shù)無(wú)效。
3、返回值
返回添加完成連接的一個(gè)新對(duì)象
4、使用實(shí)例
import pandas as pd import numpy as np df = pd.DataFrame(np.random.randint(0, 20, (3, 2)), columns=['A', 'B']) print(df) narry = np.random.randint(0, 20, (2, 2)) data = pd.DataFrame(narry, columns=['A', 'B']) print(df.append(data, ignore_index=True))
拓展知識(shí):
append函數(shù)
可以拼接一個(gè)或者多個(gè),也可以追加serise到原來(lái)的dataframe里面。
將其他行添加到此DataFrame的末尾,返回一個(gè)新對(duì)象。 不在此DataFrame中的列將作為新列添加。
以上就是pandas中使用合并append函數(shù)的相關(guān)介紹,是不是也沒(méi)有想象中的那么難,快用起來(lái)吧~
(推薦操作系統(tǒng):windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。)
分享標(biāo)題:創(chuàng)新互聯(lián)Python教程:pandas中如何使用合并append函數(shù)?
本文地址:http://www.5511xx.com/article/ccecooc.html


咨詢(xún)
建站咨詢(xún)
