【发布时间】:2021-11-29 18:15:23
【问题描述】:
我正在尝试分析 StackOverflow 调查数据,可以找到 here。
我想在“Country”列中获取“United States”中包含的所有行,然后将值存储在变量中。 例如 =
my_data = `{'Age1stCode': 12, 13, 15, 16, 18
'Country': 'India', 'China', 'United States', 'England', 'United States'
'x': 'a', 'b', 'c', 'd', 'e'
}`
我想要的 =
my_result_data = `{'Age1stCode': 15, 18
'Country': 'United States', 'United States'
'x': 'c', 'e'
}`
【问题讨论】:
-
df[df['Country'] == 'United States']或df.query('Country == "United States"')。
标签: python pandas data-analysis