How can I get a specific valuefrom the csv with using Pandas in Python?

Viewed 15
import pandas
data = pandas.read_csv('Datasets/average-height-of-men.csv')
result = data['Mean male height (cm)'].mean()
print(result) 

In the CSV Dataset, each country has an average age of more than 50 years. For example, what should I do to get only the values of Germany or France in particular? I mean all of information just about that country that i want.

data['GER'] -> Error

Columns:

['Entity', 'Code', 'Year', 'Mean male height (cm)']

Entity = Countries, Code = e.g. FIN for Finland

Example data: Example Data

1 Answers

Please, consider this code:

import pandas
data = pandas.read_csv('Datasets/average-height-of-men.csv')
data.columns = ['Full country name', 'Country name abbreviation', 'Year', 'Mean height']
data = data.loc[data['Country name abbreviation'].isin(['GER', 'FRA']),['Full country name','Mean height'])
print(data.groupby('Full country name').mean())
Related