首页 > 解决方案 > Cell value coming as series in pandas

问题描述

I'm trying to extract a cell value in pandas dataframe but it is coming as a series in the below format:

21    Employed
Name: VAR_TEXT_, dtype: object

I just want the keyword 'Employed' but getting it as pandas series.

x=df1.loc[df1['VAR_NAME_'] == 'employmentType']
x1 = x.ix[:,47]
print(x1)

sample data

data=['474400', '47', '474400', '1275', 'NULL', 'POC:32:420345', 'NULL', '474400', 'NULL', '1', '0', '1', '0', '0', '1', 'NULL', '', 'NULL', 'sid-EE2BC780-1E99-484A-BCC0-B4D9FD30A5BB', '2018-07-23 10:52:02.536', 'user_1034', 'NULL', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'NULL', 'NULL', 'POC', 'POC:32:420345', 'oopp', '32', '420317', '503780', 'employmentType', 'string', '1', '474400', '474400', 'NULL', 'NULL', 'NULL', 'Employed', 'NULL', 'NULL']
df=pd.DataFrame(data)

Note: Columns list is too long so havn't pasted it here. I tried too many options like converting the field to string but it'is still not working.

标签: pythonpandas

解决方案


如何使用.values

x=df1.loc[df1['VAR_NAME_'] == 'employmentType']
x1 = x.ix[:,47].values
print(x1)

打印出来:

Employed

推荐阅读