the-magnificents / 04-02-2021-Carpentry-for-HGIS

A carpentry workshop focused on Digital Humanities audience that works with Geospatial Data.
Other
2 stars 3 forks source link

04-02-2021-Carpentry-for-HGIS/02_Day_2_Python_GIS/exercise/B7_Exercise_Loop_Datasets #77

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Looping Over Data Sets — Python essentials for GIS learners

https://the-magnificents.github.io/04-02-2021-Carpentry-for-HGIS/02_Day_2_Python_GIS/exercise/B7_Exercise_Loop_Datasets.html

cforgaci commented 3 years ago

Exercise: Determining Matches

  1. data/gapminder_gdp_africa.csv

Exercise: Minimum File Size

import glob
import pandas as pd
fewest = 100   # a large number
for filename in glob.glob('data/data_gapminder/*.csv'):
    dataframe = pd.read_csv(filename)
    fewest = min(fewest, dataframe.shape[0])
print('smallest file has', fewest, 'records')

Result:

smallest file has 2 records

Exercise: Comparing Data The following program works, but I don't know how to label the regions in the legend

for filename in glob.glob('data/data_gapminder/gapminder_gdp_*.csv'):
    data = pd.read_csv(filename)
    data.mean().plot()
    plt.legend(loc='best')
    plt.xticks(rotation=90)