Pandas

From Wildsong
Jump to navigationJump to search

All this stuff is amazing but hard to wrap my head around because it's more like working with SQL than nice linear procedural programming.

When something is hard for me, I write about it in my Wiki.

This page currently is really all about GeoPandas, for now.

There is also the ArcGIS version and I should write about that here too.

Pandas

This is a Python package for manipulating data that implements dataframes. Dataframes are well amazing. Also extremely well documented elsewhere.

So run along and learn Pandas THEN come back and learn GeoPandas.

Esri "ArcGIS API for Python"

Yeah so you can go install this and learn about it, docs are... difficult.

GeoPandas

GeoPandas is geospatially enabled Pandas. Go right to the page for full info, https://geopandas.org.

Installation

I have an OSGEO env so I added Geopandas to it. I said "conda install geopandas" and it said

 attrs              conda-forge/noarch::attrs-20.3.0-pyhd3deb0d_0
 boost-cpp          conda-forge/win-64::boost-cpp-1.74.0-h54f0996_2
 bzip2              conda-forge/win-64::bzip2-1.0.8-h8ffe710_4
 cairo              conda-forge/win-64::cairo-1.16.0-hb19e0ff_1008
 cfitsio            conda-forge/win-64::cfitsio-3.470-h0af3d06_7
 click              conda-forge/noarch::click-7.1.2-pyh9f0ad1d_0
 click-plugins      conda-forge/noarch::click-plugins-1.1.1-py_0
 cligj              conda-forge/noarch::cligj-0.7.1-pyhd8ed1ab_0
 curl               conda-forge/win-64::curl-7.75.0-hf1763fc_0
 expat              conda-forge/win-64::expat-2.2.10-h39d44d4_0
 fiona              conda-forge/win-64::fiona-1.8.18-py36hdce5812_1
 fontconfig         conda-forge/win-64::fontconfig-2.13.1-h1989441_1004
 freetype           conda-forge/win-64::freetype-2.10.4-h546665d_1
 freexl             conda-forge/win-64::freexl-1.0.6-ha8e266a_0
 gdal               conda-forge/win-64::gdal-3.2.2-py36hfaf0fdc_0
 geopandas          conda-forge/noarch::geopandas-0.9.0-pyhd8ed1ab_0
 geos               conda-forge/win-64::geos-3.9.1-h39d44d4_2
 geotiff            conda-forge/win-64::geotiff-1.6.0-h8e90983_5
 librttopo          conda-forge/win-64::librttopo-1.1.0-hb340de5_6
 libspatialindex    conda-forge/win-64::libspatialindex-1.9.3-h39d44d4_3
 libspatialite      conda-forge/win-64::libspatialite-5.0.1-h6b539a6_4
 libssh2            conda-forge/win-64::libssh2-1.9.0-h680486a_6
 libtiff            conda-forge/win-64::libtiff-4.2.0-hc10be44_0
 libwebp-base       conda-forge/win-64::libwebp-base-1.2.0-h8ffe710_2
 libxml2            conda-forge/win-64::libxml2-2.9.10-hf5bbc77_3
 lz4-c              conda-forge/win-64::lz4-c-1.9.3-h8ffe710_0
 mkl                conda-forge/win-64::mkl-2020.4-hb70f87d_311
 munch              conda-forge/noarch::munch-2.5.0-py_0
 numpy              conda-forge/win-64::numpy-1.19.5-py36hd1b969e_1
 openjpeg           conda-forge/win-64::openjpeg-2.4.0-h48faf41_0
 pandas             conda-forge/win-64::pandas-1.1.5-py36he38d939_0
 pcre               conda-forge/win-64::pcre-8.44-ha925a31_0
 pixman             conda-forge/win-64::pixman-0.40.0-h8ffe710_0
 poppler            conda-forge/win-64::poppler-21.03.0-h9ff6ed8_0
 poppler-data       conda-forge/noarch::poppler-data-0.4.10-0
 postgresql         conda-forge/win-64::postgresql-13.1-h0f1a9bc_2
 proj               conda-forge/win-64::proj-8.0.0-h1cfcee9_0
 pyproj             conda-forge/win-64::pyproj-3.0.1-py36h86093ec_1
 python-dateutil    conda-forge/noarch::python-dateutil-2.8.1-py_0
 pytz               conda-forge/noarch::pytz-2021.1-pyhd8ed1ab_0
 rtree              pkgs/main/win-64::rtree-0.9.4-py36h21ff451_1
 shapely            conda-forge/win-64::shapely-1.7.1-py36hd33d9d6_4
 sqlite             conda-forge/win-64::sqlite-3.35.2-h8ffe710_0
 tiledb             conda-forge/win-64::tiledb-2.2.7-hf84e3da_0
 tk                 conda-forge/win-64::tk-8.6.10-h8ffe710_1
 xerces-c           conda-forge/win-64::xerces-c-3.2.3-h0e60522_2
 xz                 conda-forge/win-64::xz-5.2.5-h62dcd97_1
 zlib               conda-forge/win-64::zlib-1.2.11-h62dcd97_1010
 zstd               conda-forge/win-64::zstd-1.4.9-h6255e5f_0

ZOW. Now I wonder what was in there in the first place before installing geopandas. Lots of good stuff in these dependencies like gdal and fiona and proj and geos.

Hello World from GeoPandas

In VSCODE, start a Jupyter Notebook. Well, first,

conda install jupyter

References

Mastering pandas - Second Edition has a short but sweet chapter on GeoPandas.

Learning Geospatial Analysis with Python - Third Edition has just a brief description of GeoPandas

There are some older references in O'Reilly as well.

This video with Andy Eschbacher has some talk about GeoPandas starting at about 30:00 More tools to look at (ugh): matplotlib, Folium