Python3.x-从数据帧中提取字符串

Python3.x-从数据帧中提取字符串,python,pandas,dataframe,Python,Pandas,Dataframe,假设数据帧df- df = pd.DataFrame(['a']) 我想从这个数据帧中提取字符串“a”。我试着从stackoverflow答案中提取它- 尝试1— print(df.iloc[0]) >>0 a Name: 0, dtype: object 尝试2- print(df.astype(str)) >> 0 0 a 请帮助我从dataframe中提取字符串“a”,并从dataframe中获取第一个系列。如果您想要该系列的第一个元素,您应该使用它

假设数据帧df-

df = pd.DataFrame(['a'])
我想从这个数据帧中提取字符串“a”。我试着从stackoverflow答案中提取它- 尝试1—

print(df.iloc[0])
>>0    a
Name: 0, dtype: object
尝试2-

print(df.astype(str))
>>  0
0  a
请帮助我从dataframe中提取字符串“a”,并从dataframe中获取第一个系列。如果您想要该系列的第一个元素,您应该使用它两次或与
iloc[0][0]

In [57]: df.iloc[0][0]
Out[57]: 'a'

In [58]: df.iloc[0].iloc[0]
Out[58]: 'a'