pd.concat
时间: 2023-07-12 17:17:49 浏览: 91
`pd.concat` is a function provided by the Pandas library in Python. It is used to concatenate two or more Pandas data frames along a particular axis, either row-wise or column-wise. The syntax for using `pd.concat` is as follows:
```
pd.concat(objs, axis=0, join='outer', ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, sort=False, copy=True)
```
Here, `objs` refers to a sequence or mapping of Pandas data frames that need to be concatenated. The other parameters are optional and allow you to specify how the concatenation should be performed.
For example, to concatenate two data frames `df1` and `df2` vertically (i.e., row-wise), you can use the following code:
```
result = pd.concat([df1, df2], axis=0)
```
Similarly, to concatenate them horizontally (i.e., column-wise), you can use the following code:
```
result = pd.concat([df1, df2], axis=1)
```
Note that `pd.concat` returns a new data frame that contains the concatenated data. It does not modify the original data frames.
阅读全文