meta data for this page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
software:python [2017/06/20 17:48] – added prj translation info christiansoftware:python [2020/08/08 22:15] – [Pandas/Geopandas] christian
Line 1: Line 1:
 Useful links and snippets regarding Python and Jupyter notebooks Useful links and snippets regarding Python and Jupyter notebooks
 +
 +====== Modules ======
 +
 +  * The uncompromising Python code formatter [[https://black.readthedocs.io/en/stable/]] and on Github: [[https://github.com/psf/black]]
 +
  
 ===== iPython/Jupyter resources ===== ===== iPython/Jupyter resources =====
Line 7: Line 12:
   * [[http://jupyter.readthedocs.io/en/latest/index.html|Jupyter notebooks documentation]]   * [[http://jupyter.readthedocs.io/en/latest/index.html|Jupyter notebooks documentation]]
   * [[http://matplotlib.org/examples/color/colormaps_reference.html|Matplotlib colormaps]] and [[https://stackoverflow.com/questions/3373256/set-colorbar-range-in-matplotlib| how to normalise a colormap]]   * [[http://matplotlib.org/examples/color/colormaps_reference.html|Matplotlib colormaps]] and [[https://stackoverflow.com/questions/3373256/set-colorbar-range-in-matplotlib| how to normalise a colormap]]
 +  * [[https://maxmasnick.com/projects/scipy-tips/|Max Masnick's Dat science Python snippets]]
 +  * [[https://realpython.com/python-matplotlib-guide/|MatPlotLib guide]]
  
  
Line 31: Line 38:
 Proj4 is: <string with proj4 parameters follows> Proj4 is: <string with proj4 parameters follows>
 </code> </code>
 +
 +
 +==== Pandas/Geopandas ====
 +
 +  * Invert a single column of a Pandas Dataframe: ''df.col2 = df.col2.values[::-1]'' [[https://stackoverflow.com/questions/46244235/invert-a-single-column-in-a-dataframe|via StackOverflow]]
 +  * Joining multiple overlapping column names from multiple dataframes: ''pd.concat(data, axis=1)'' [[https://stackoverflow.com/questions/13003769/joining-multiple-dataframes-with-pandas-with-overlapping-column-names|via StackOverflow]]
 +  * Cross-section indexing of a multi-indexed dataframe - using levels: ''concatdf.xs('MIndexValue', level='MIndexName')'' - [[http://pandas-docs.github.io/pandas-docs-travis/user_guide/advanced.html#advanced-xs|via Pandas documentation]] and [[https://stackoverflow.com/questions/24435788/using-loc-with-a-multiindex-in-pandas#24436783|StackOverflow]]
 +  * [[https://stackoverflow.com/questions/53645882/pandas-merging-101|Pandas merging 101]] on StackOverflow.
 +  * Going from a regular dataframe to geopandas data frame: ''gdf = geopandas.GeoDataFrame(df, geometry=geopandas.points_from_xy(df.Longitude, df.Latitude))'' -- [[https://geopandas.readthedocs.io/en/latest/gallery/create_geopandas_from_pandas.html|via Geopandas doc]]
 +  * Obtaining unique values for Multi-index levels: ''concatdf.index.unique(level=1)''
 +  * Drop a level of multi-index into a column: ''df.reset_index(level=[...])'' - via [[https://stackoverflow.com/questions/20110170/turn-pandas-multi-index-into-column|StackOverflow]]
  
  
Line 37: Line 55:
 ===== Stuff related to modules ===== ===== Stuff related to modules =====
  
-  * [[osgeo.ogr]]+  * [[https://gdal.org/python/osgeo.ogr-module.html|osgeo.ogr]]
   * [[http://effbot.org/zone/import-confusion.htm|Importing modules - effbot's import confusion]]   * [[http://effbot.org/zone/import-confusion.htm|Importing modules - effbot's import confusion]]
   * Installing a new module in Enthough Canopy Light's distro on Windows: I managed to install the [[https://pypi.python.org/pypi/dbf|DBF module]] by navigating to the unzipped content downloaded in the Python console. Then I just typed ''%run setup.py install'' and the compiled module is then installed in the Canopy's ''User\Lib\site-packages'' directory. Easy.   * Installing a new module in Enthough Canopy Light's distro on Windows: I managed to install the [[https://pypi.python.org/pypi/dbf|DBF module]] by navigating to the unzipped content downloaded in the Python console. Then I just typed ''%run setup.py install'' and the compiled module is then installed in the Canopy's ''User\Lib\site-packages'' directory. Easy.
  
-{{tag> Python Programming Jupyter iPython notebooks}}+{{tag> Python Programming Jupyter iPython notebooks pandas}}