简体   繁体   English

如何使用 python 从 pandas 数据帧中获取特定值?

[英]How to get specific values in from a pandas data frame using python?

I'm trying to run the script below:我正在尝试运行以下脚本:

g20s = ['Argentina, Australia, Brazil, Canada, China, France, Germany, India, Indonesia, Italy, Japan, Mexico, Republic of Korea, Russia, Saudi Arabia, South Africa, Turkey, United Kingdom, United States, European Union']

gdp_g20 = gdp_world.loc(gdp_world['Country Name'].isin(g20s))

But I'm gettin the error below:但我遇到了以下错误:

TypeError: 'Series' objects are mutable, thus they cannot be hashed TypeError:“系列”对象是可变的,因此它们不能被散列

Any idea of how get these values from the dataframe without having this problem?知道如何从 dataframe 获得这些值而不会出现此问题吗?

Thanks a lot!非常感谢!

Your problem is the "(" and ")"你的问题是“(”和“)”

Try this: gdp_g20 = gdp_world[gdp_world['Country Name'].isin(g20s)]试试这个:gdp_g20 = gdp_world[gdp_world['Country Name'].isin(g20s)]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从数据框中获取特定值,使用 pandas 绘制图形 - How to get specific values from data frame, using pandas to graph 如何在python中使用pandas以特定方式从数据框中选择数据 - How to select data from data-frame in a specific manner using pandas in python Pandas Python:如何每10步获取数据框上的值? - Pandas Python: how to get values on data frame every 10 steps? 如何从python pandas数据框中提取特定值? - How to pull out a specific value from a python pandas data frame? 如何使用 pandas 根据同一数据帧中另一列的条件获取列值的连续平均值 - How to get consecutive averages of the column values based on the condition from another column in the same data frame using pandas Python/Pandas:如何根据个人 ID 替换 Pandas 数据框的特定值? - Python/Pandas: How do I replace specific values of a Pandas Data Frame based on individual id? 具有其他数据框(pandas,python)中唯一值的数据框 - Data frame with unique values from other data frame(pandas, python) 如何使用多列中的值对pandas数据框进行排序? - How to sort pandas data frame using values from several columns? 如何使用python从网页抓取中创建pandas数据框 - How to create a pandas data frame from web scraping using python 使用python更改特定pandas数据框列中的行值 - Change row values in specific pandas data frame column with python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM