python - 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.
解决方案
如何使用.values
:
x=df1.loc[df1['VAR_NAME_'] == 'employmentType']
x1 = x.ix[:,47].values
print(x1)
打印出来:
Employed
推荐阅读
- python - 在基于 cPanel Linux 的终端中运行 selenium 时,可执行文件可能有错误的权限错误
- html - 按钮上应用的奇怪样式
- python - For 循环仅执行列表中的第一个对象
- sas - proc报告中跨变量拆分的变量的不同标签
- c++ - 将 2 个 openssl 与 libcurl 链接时:错误设置证书验证位置
- ios - 是否可以检测附近没有我的应用的 iOS 设备?
- c# - 有没有办法将本地数据库与 Azure 上托管的 ASP.NET 核心 Web 应用程序一起使用?
- javascript - Threejs - 动画 fjdxsu 的公式
- sql - 如何连接两列,其中表 A 的日期介于 Oracle SQL 中表 B 的日期之间?
- dataframe - 如何连接具有列值的表