长虫山小木屋

没有谁会为你踏雪而来 喜欢的风景要躬亲筚路

  博客园  :: 首页  :: 新随笔  :: 联系 ::  :: 管理

不多说看代码:

import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randn(5,4))
df1 = pd.DataFrame(np.random.randn(3,4))
df2 = pd.DataFrame(np.random.randn(3,4))
print(df)
print(df.iloc[0:3,:])#切开前三行
print(df1)
print(df2)
print(pd.concat([df1, df2], ignore_index=True))#合并df1+df2

运行结果:

          0         1         2         3
0 -0.905734 -1.984248 -0.804332 -0.659593
1 -1.903482 -0.432071  0.149107 -1.125988
2 -1.811088  0.128598  0.958648 -0.059884
3  1.914469 -0.155695  1.475895  0.131296
4  0.990463  1.515627 -0.875387 -1.397807
          0         1         2         3
0 -0.905734 -1.984248 -0.804332 -0.659593
1 -1.903482 -0.432071  0.149107 -1.125988
2 -1.811088  0.128598  0.958648 -0.059884
          0         1         2         3
0  0.100466  1.506926  1.509604  0.727146
1 -0.954037  0.572776  1.393201  1.406746
2 -0.706245  0.408888 -1.581230 -0.565017
          0         1         2         3
0 -0.458960 -0.246514 -0.340165  0.987064
1  0.829132  0.465937 -0.285688 -0.953261
2 -0.562739 -0.630129  0.846015  1.387031
          0         1         2         3
0  0.100466  1.506926  1.509604  0.727146
1 -0.954037  0.572776  1.393201  1.406746
2 -0.706245  0.408888 -1.581230 -0.565017
3 -0.458960 -0.246514 -0.340165  0.987064
4  0.829132  0.465937 -0.285688 -0.953261
5 -0.562739 -0.630129  0.846015  1.387031

Process finished with exit code 0
posted on 2020-04-13 10:38  长虫山小木屋  阅读(3434)  评论(0编辑  收藏  举报