Introduction to
Pandas and GeoPandas
Ujaval Gandhi
ujaval@spatialthoughts.com
Python Foundation for Spatial Analysis
Pandas Basics
Pandas
Basic Terminology
| col 1 | col 2 | col 3 | … | col n |
row 1 | | | | | |
row 2 | | | | | |
row 3 | | | | | |
… | | | | | |
row n | | | | | |
DataFrame
Series
Pandas Selection
| col 1 | col 2 | col 3 | … | col n |
row 1 | | | | | |
row 2 | | | | | |
row 3 | | | | | |
… | | | | | |
row n | | | | | |
Columns have Index and label
Rows have Index*
*You can optionally assign a column to be row labels
index |
0 |
1 |
2 |
.. |
n |
Pandas Index
Select by Index
Pandas provides a shortcut for selecting rows by index
Select by Label
Pandas provides a shortcut for selecting columns by labels
In Summary
In practice, we recommend
Pandas Filtering
Filtering DataFrames
Pandas Calculations
Performing Calculations
apply()
GeoPandas Basics
GeoPandas
Basic Terminology