310
Kommentar:
|
4698
|
Gelöschter Text ist auf diese Art markiert. | Hinzugefügter Text ist auf diese Art markiert. |
Zeile 1: | Zeile 1: |
#format rst PyDLR3 ======= * Eric Matthes, Python Crash Course, 2nd edition, 2019, Cheat Sheets https://ehmatthes.github.io/pcc_2e/ |
|
Zeile 3: | Zeile 10: |
## PyDLR31 | PyDLR32 ======= |
Zeile 5: | Zeile 13: |
{{{ # UnboundLocalError: local variable 'D' referenced before assignment # Python Introductory Course 8.-10. April 2019 # Python 3.7 |
Juli 2019 |
Zeile 10: | Zeile 15: |
D = {} | * Python - die Alternative zu Matlab? http://num.math.uni-goettingen.de/~schulz/data/python_talk.pdf |
Zeile 12: | Zeile 18: |
def foo(): if False: D = {} D["blue"] = "blau" print("D local:", D) return D |
* Glumpy is a python library for scientific visualization that is both fast, scalable and beautiful. Glumpy offers an intuitive interface between numpy and modern OpenGL. http://glumpy.github.io Python & OpenGL for Scientific Visualization, Copyright (c) 2018 Nicolas P. Rougier, License: Creative Commons Attribution 4.0 International (CC BY-NC-SA 4.0), Website: http://www.labri.fr/perso/nrougier/python-opengl http://www.labri.fr/perso/nrougier/python-opengl/ * https://github.com/rougier/matplotlib-tutorial * Python 4 Everybody by Charles Severance, https://www.py4e.com (free book) PyDLR31 ======= April 2019 :: # UnboundLocalError: local variable 'D' referenced before assignment # Python Introductory Course 8.-10. April 2019 # Python 3.7 D = {} def foo(): if False: D = {} D["blue"] = "blau" print("D local:", D) return D |
Zeile 20: | Zeile 56: |
D = foo() print(D) |
D = foo() print(D) |
Zeile 23: | Zeile 59: |
}}} | # shorter: # 1. Line '*' commented out: NameError: name 'D' is not defined # 2. With line '*': UnboundLocalError: local variable 'D' referenced before assignment # 3. With 'if True': works def g(): if False: D = {} # (*) print(D) g() Explanation: - https://docs.python.org/3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value - https://eli.thegreenplace.net/2011/05/15/understanding-unboundlocalerror-in-python PyDLR23 ======= Switch/Case with Python :: def a(): print("'a' was called") def b(): print("'b' was called") def c(): print("'c' was called") D = { 'a' : a, 'b' : b, 'c' : c} while True: s = input("your choice: ") if s in D: D[s]() else: break PyDLR22 ======= Python 3 -------- * Jake VanderPlas, A Whirlwind Tour of Python (freier Text mit 100 Seiten plus Jupyter Notebooks) https://github.com/jakevdp/WhirlwindTourOfPython * Kevin Sheppard, Python for Econometrics, 2017 https://www.kevinsheppard.com/Python_for_Econometrics SciPy ----- * http://www.scipy-lectures.org (inkl. Datensaetzen und Aufgaben) - Numpy http://www.scipy-lectures.org/intro/numpy/index.html - Matplotlib http://www.scipy-lectures.org/intro/matplotlib/index.html - SciPy http://www.scipy-lectures.org/intro/matplotlib/index.html - Statistics (ein wenig Pandas) http://www.scipy-lectures.org/packages/statistics/index.html * Matplotlib Gallery (viele Beispiele mit Sourcecode) http://matplotlib.org/gallery.html * Hans Petter Langtangen, A very basic introduction to scientific Python programming, 2016 http://hplgit.github.io/bumpy/doc/pub/basics.html * Svein Linge, Hans Petter Langtangen, Programming for Computations - Python A Gentle Introduction to Numerical Simulations with Python, 2016 (Open Access) http://link.springer.com/book/10.1007%2F978-3-319-32428-9 Pandas ------ * Pandas Homepage, siehe *10 Minutes to Pandas*, *Tutorials*, *Lessons for new Pandas users*, ... http://pandas.pydata.org/pandas-docs/stable/ * Beispiele aus dem Netz, leicht modifiziert. U.a. Excel Writer, Pandas Reader, Pandas Zeitserie, Numpy: Textdateien einlesen, ... http://www.hhoegl.de/start_python/bookonl/demos/py_data_io/ * Karlijn Willems, Pandas Tutorial: DataFrames in Python, October 2016 * https://www.datacamp.com/community/tutorials/pandas-tutorial-dataframe-python * http://www.analyticsvidhya.com/blog/2015/04/comprehensive-guide-data-exploration-sas-using-python-numpy-scipy-matplotlib-pandas/ * http://blog.brakmic.com/data-science-for-losers * Wes McKinney, Python for Data Analysis, O'Reilly 2013. * Cheat sheets - https://github.com/pandas-dev/pandas/blob/master/doc/cheatsheet/Pandas_Cheat_Sheet.pdf - https://www.datacamp.com/community/blog/python-pandas-cheat-sheet#gs.EBTvnMY |
PyDLR3
- Eric Matthes, Python Crash Course, 2nd edition, 2019, Cheat Sheets https://ehmatthes.github.io/pcc_2e/
PyDLR32
Juli 2019
Python - die Alternative zu Matlab? http://num.math.uni-goettingen.de/~schulz/data/python_talk.pdf
Glumpy is a python library for scientific visualization that is both fast, scalable and beautiful. Glumpy offers an intuitive interface between numpy and modern OpenGL.
Python & OpenGL for Scientific Visualization, Copyright (c) 2018 Nicolas P. Rougier, License: Creative Commons Attribution 4.0 International (CC BY-NC-SA 4.0), Website: http://www.labri.fr/perso/nrougier/python-opengl
Python 4 Everybody by Charles Severance, https://www.py4e.com (free book)
PyDLR31
April 2019
# UnboundLocalError: local variable 'D' referenced before assignment # Python Introductory Course 8.-10. April 2019 # Python 3.7 D = {} def foo(): if False: D = {} D["blue"] = "blau" print("D local:", D) return D D = foo() print(D) # shorter: # 1. Line '*' commented out: NameError: name 'D' is not defined # 2. With line '*': UnboundLocalError: local variable 'D' referenced before assignment # 3. With 'if True': works def g(): if False: D = {} # (*) print(D) g()
Explanation:
PyDLR23
Switch/Case with Python
def a(): print("'a' was called") def b(): print("'b' was called") def c(): print("'c' was called") D = { 'a' : a, 'b' : b, 'c' : c} while True: s = input("your choice: ") if s in D: D[s]() else: break
PyDLR22
Python 3
Jake VanderPlas, A Whirlwind Tour of Python (freier Text mit 100 Seiten plus Jupyter Notebooks)
Kevin Sheppard, Python for Econometrics, 2017
SciPy
http://www.scipy-lectures.org (inkl. Datensaetzen und Aufgaben)
Matplotlib Gallery (viele Beispiele mit Sourcecode)
Hans Petter Langtangen, A very basic introduction to scientific Python programming, 2016
Svein Linge, Hans Petter Langtangen, Programming for Computations - Python A Gentle Introduction to Numerical Simulations with Python, 2016 (Open Access)
Pandas
Pandas Homepage, siehe 10 Minutes to Pandas, Tutorials, Lessons for new Pandas users, ...
Beispiele aus dem Netz, leicht modifiziert. U.a. Excel Writer, Pandas Reader, Pandas Zeitserie, Numpy: Textdateien einlesen, ...
Karlijn Willems, Pandas Tutorial: DataFrames in Python, October 2016
https://www.datacamp.com/community/tutorials/pandas-tutorial-dataframe-python
Wes McKinney, Python for Data Analysis, O'Reilly 2013.
Cheat sheets