1 / 14

Useful Python Libraries

Useful Python Libraries. Ghislain Prince. This presentation. Standard libraries “batteries included” 3 rd party libs. Regarding python 3. docs.python.org/2/library/2to3.html “Analyze tools for Pro” tool Future : pick you python (Conda).

Télécharger la présentation

Useful Python Libraries

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Useful Python Libraries Ghislain Prince

  2. This presentation • Standard libraries • “batteries included” • 3rd party libs

  3. Regarding python 3 • docs.python.org/2/library/2to3.html • “Analyze tools for Pro” tool • Future : pick you python (Conda)

  4. Standard Library is Large, powerful and Well-Documented • docs.python.org • Installed with ArcGIS

  5. 3rd Party Library • Not part of standard library • Pypi – the Python Package Index • 60,000+ packages • https://pypi.python.org/pypi • pip • C:\>c:\Python27\ArcGIS10.3\Scripts\pip.exe install requests • Downloading requests-2.7.0-py2.py3-none-any.whl (470kB) • 100% |################################| 471kB 718kB/s • Installing collected packages: requests • Successfully installed requests-2.7.0

  6. Data Formats • XML • JSON • CSV • Excel • PDF • Numpy/Pandas* • NetCDF

  7. 3 XML options within the standard library • SAX • Can handle huge datasets • Hard to use, verbose code • DOM • Familiar: Javascript uses the DOM • Easy (ish) • Etree • Feels like python • Extremely easy and concise for common tasks

  8. JSON • json module >>> import json >>> d = json.load(open("states.json", 'r')) >>> print(type(d)) <class 'dict'>

  9. CSV & Excel • csv module >>> import csv >>> with open('eggs.csv', 'rb') as csvfile: ... spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|') ... for row in spamreader: ... print ', '.join(row) Spam, Spam, Spam, Spam, Spam, Baked Beans Spam, Lovely Spam, Wonderful Spam • xlrd & xlwt (third-party, included in ArcGIS) Sample from python.org

  10. PDF • arcpy.mapping.PDFDocument • reportlab (third-party) • allows rapid creation of rich PDF documents, and also creation of charts in a varietyof bitmap and vector formats.

  11. Networking • Calls to HTTP servers • urllib2 • requests (third-party, pip-install) • asyncio

  12. Computing • Numpy • Pandas * • Scipy * • Sympy * • R bridge (coming soon: github.com/R-ArcGIS … wait this isn’t python at all) • * Pro 1.0 & planned for Desktop/Server 10.4

  13. Resources arcpy.wordpress.com twitter.com/arcpy desktop.arcgis.com/en/desktop/

More Related