可以将Pandas Series转换为DataFrame,并通过concat函数连接,再给DataFrame指定列名。示例代码如下:
import pandas as pd
# 创建Pandas Series
s1 = pd.Series([1, 2, 3])
s2 = pd.Series([4, 5, 6])
# 将Pandas Series转换为DataFrame,并指定列名
df1 = pd.DataFrame(s1, columns=['A'])
df2 = pd.DataFrame(s2, columns=['B'])
# 使用concat函数连接DataFrame
df = pd.concat([df1, df2], axis=1)
print(df)
# 输出:
# A B
# 0 1 4
# 1 2 5
# 2 3 6
下一篇:不能更改安装路径的文件提取器