学堂 学堂 学堂公众号手机端

pd.contact,dataframe 拼接

lewis 1年前 (2024-04-19) 阅读数 21 #技术
a=np.random.choice(10,(3,4))
b=np.random.choice((100,500),(3,4))
df1=pd.DataFrame(a,columns=["x1","x2","x3","x4"],index=["a","b","c"])
df2=pd.DataFrame(b,columns=["x1","x2","x3","x4"],index=["b","c","d"])
print(pd.concat([df1,df2],ignore_index=False))

  

# ignore_index=True todo index default: 0,1,2,.....


# ignore_index False a,b,c,b,c,d



版权声明

本文仅代表作者观点,不代表博信信息网立场。

热门