- Docente: Pietro Rossi
- Credits: 6
- SSD: SECS-P/01
- Language: English
- Teaching Mode: Traditional lectures
- Campus: Bologna
-
Corso:
Second cycle degree programme (LM) in
Economics and Public Policy (cod. 5945)
Also valid for Second cycle degree programme (LM) in Applied Economics and Markets (cod. 5969)
-
from Apr 09, 2025 to May 15, 2025
Learning outcomes
This course provides theory and tools for using Python as a programming language in economic research. It (i) introduces students to the basic logic and syntax of Python (e.g. object-oriented programming) and (ii) emphasizes how to use it to perform Data Science-related tasks (working with relational dataset, big data, data visualization, among others).
Course contents
Basic Python
- Using the Python Interpreter
- An Informal Introduction to Python
- Control Flow Tools
- Data Structures
- Modules
- Input and Output
- Errors and Exceptions
- Classes
- Brief Tour of the Standard Library
- Virtual Environments and Packages
NumPy
- Array objects
The N-dimensional array (ndarray)
Scalars
Data type objects (dtype)
Indexing routines
Iterating Over Arrays
Standard array subclasses
Masked arrays
The array interface protocol
Datetimes and Timedeltas
- Constants
- Routines
Array creation routines
Array manipulation routines
Binary operations
String operations
Mathematical functions with automatic domain
Floating point error handling
Functional programming
NumPy-specific help functions
Input and output
Linear algebra (numpy.linalg)
Logic functions
Masked array operations
Mathematical functions
Miscellaneous routines
Random sampling (numpy.random)
Set routines
Sorting, searching, and counting
Statistics
SciPy
Introduction
Special functions (scipy.special)
Integration (scipy.integrate)
Optimization (scipy.optimize)
Interpolation (scipy.interpolate)
Linear Algebra (scipy.linalg)
Statistics (scipy.stats)
pandas
- basics
Object creation
Viewing data
Selection
Missing data
Operations
Merge
Grouping
Reshaping
Time series
Categoricals
Plotting
Getting data in/out
Gotchas - Intro to data structures
- Essential basic functionality
- IO tools (text, CSV, HDF5, …)
- Indexing and selecting data
- MultiIndex / advanced indexing
- Merge, join, concatenate and compare
- Reshaping and pivot tables
- Working with text data
- Working with missing data
- Categorical data
- Computational tools
- Group by: split-apply-combine
Elements of matplotlib
Readings/Bibliography
https://docs.python.org/3/tutorial/
https://numpy.org/doc/stable/reference/index.html
https://docs.scipy.org/doc/scipy/tutorial/index.html
https://pandas.pydata.org/docs/getting_started/tutorials.html
https://matplotlib.org/stable/tutorials/introductory/index.html
Teaching methods
In presence.
Teacher explaining concepts and discussing exercises
Assessment methods
Through the course there will be 2 or 3 home assignment that students are expected to do and return to the tutor for grading.
Home assigned are tailored to occupy the student from 1 to 2 hours.
Final exam will be a written exam consisting in a challenging programming task.
Th final grade will be weighted equal between home assignment and the final exam.
Writing a computer program entails, among other three aspects I want to emphasize: correctness, clean programming style and performance. Correctness will absorb 60% of the value, coding style will weight 30%, the remaining 10% is taken up by performance
Teaching tools
Most will be frontal lectures were the teacher explains concepts and discusses examples.
Python code will be showcased both as standalone scripts, developed within an IDE but most of all examples will be presented via the Notebook.
The most important tool will be the large number of exercises that will be proposed and will challenge the student.
Office hours
See the website of Pietro Rossi