Pandas
Learning outcomes
At the end of this sessions, learners …
understand why Pandas is important
have run Python code that uses Pandas
Loading Pandas
HPC cluster |
How to load Pandas |
|---|---|
Alvis |
|
COSMOS |
|
Dardel |
|
Kebnekaise |
|
Pelle |
|
Tetralith |
|
Exercises
Exercise 1: minimal code
Get this code to run:
import pandas
print(pandas.__version__)
Exercise 2
Depends on Matplotlib
Series:
#
data = pd.Series([0.25, 0.5, 0.75, 1.0])
data = pd.Series({2:'a', 1:'b', 3:'c'})
print(data.values)
Data frame:
population_dict = {'California': 38332521,
'Texas': 26448193,
'New York': 19651127,
'Florida': 19552860,
'Illinois': 12882135}
population = pd.Series(population_dict)
population
area_dict = {'California': 423967, 'Texas': 695662, 'New York': 141297,
'Florida': 170312, 'Illinois': 149995}
area = pd.Series(area_dict)
area
states = pd.DataFrame({'population': population,
'area': area})
states