0
Follow
0
View

python: how can I access an element in a pandas series contained in a dictionary

dls081x 注册会员
2023-01-25 05:47

If select in dictionary of DataFrames by key get DataFrame, then convert Team to index, so possible use DataFrame.loc:

df = d['Group A']

out = df.set_index('Team').loc['Senegal', 'Pos']

Or use DataFrame.loc with boolean indexing - but then necessary convert one element Series to scalar:

out = df.loc[df['Team'].eq('Senegal'), 'Pos'].iat[0]

out = next(iter(df.loc[df['Team'].eq('Senegal'), 'Pos']), 'no match')

About the Author

Question Info

Publish Time
2023-01-25 05:47
Update Time
2023-01-25 05:47

Related Question

python程序运行不了

Xcode 14.2和Flutter版本3.3.10中flutter_inappwebview-5.7.2+3插件错误

Internet选项异常怎么处理

虚拟机被宿主机用Xshell连接后不能ping通外网

python 外星人入侵 子弹不显示

如何用python检查mysql表

如何创建一个PDF页码列表,如果PDF页包含特定的文本字符串使用python

通过azure管道使用bastion连接Linux虚拟机

我如何从我的PyQt5 UI输入传递数据到我的python程序?

在linux上用mail命令时报错