Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
67 views
in Technique[技术] by (71.8m points)

python - Why am I getting an error while using 'data.loc' for a specific column?

I am working on a dataset by WHO on Google Collab.

For some columns, 'data.loc' is working completely. For example:

  1. data.loc[(data['Country'] == 'Bangladesh'), ['Country', 'Year', 'infant deaths']]
  2. data.loc[(data['Country'] == 'Bangladesh'), ['Country', 'Year','Adult Mortality']]

However, there is a column called 'Life expectancy'. I have checked multiple times whether I mistyped or not. But every time I want to see columns having a 'Life expectancy' value for Bangladesh, I get an error message/response.

Code used:

  1. data.loc[(data['Country'] == 'Bangladesh'), ['Life expectancy']]

Error Image:

enter image description here

My First 5 columns for better visualization of my dataset:

enter image description here

question from:https://stackoverflow.com/questions/65941856/why-am-i-getting-an-error-while-using-data-loc-for-a-specific-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...