📜  从系列到数据框的熊猫 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:21.777000             🧑  作者: Mango

代码示例4
import pandas as pd

data = {'First_Name': ['Jeff','Tina','Ben','Maria','Rob']}
df = pd.DataFrame(data, columns = ['First_Name'])

print(df)
#    First_Name
#0       Jeff
#1       Tina
#2        Ben
#3      Maria
#4        Rob

print(type(df))
# 

df = df.squeeze() # <- Converts to a pandas series
print(df)
#0     Jeff
#1     Tina
#2      Ben
#3    Maria
#4      Rob
#Name: First_Name, dtype: object

print(type(df))
#