Intro to Python for Scientists
Detailed introduction to programming with Python including data analysis with Numpy and Pandas, visualization with Matplotlib, and statistical tests using real neuroscience data.
Authors
Python is one of the most widely used programming languages in academia and beyond. This one-day, hands-on course will teach how to use Python and manage scientific coding projects. Participants will learn how to organize and analyze data using the Numpy and Pandas Libraries, visualize data using Matplotlib and Seaborn and perform statistical tests using Pingouin. By analysing real data from neuroscience and other discipines, participants will acquire the confidence to use Python in their own projects. Assignments are organized in Jupyter Notebooks that participants will collaborate on and solve in small teams of 2-3 people, providing an environment where all can learn from each other’s experiences.
Credits
Installation
To run the course materials on your own machine, it is recommended that you:
- Install VSCode as your editor
- Install pixi or alternatively conda to create virtual Python environments (see the lessons on environment and package management)
- Create a dedicated folder for this course and install the virtual environment:
Download the pixi.toml file and install the environment:
pixi install --manifest-path pixi.toml
pixi shellDownload the environment.yml file and install the environment:
conda env create -f environment.yml
conda activate intro_python_longCourse Contents
Intro to Python
Object-Oriented Python: Types, Objects, and Methods
Learn the fundamental concepts in the Python ecosystem
Parsing Metadata from Filenames
Extract structured metadata from filenames using string manipulation techniques
Strings and Methods
Strings for handling text data. Methods and polymorphism
Core Data Collections and Numpy Functions
Learn how to work with data in Python collections, the benefits of NumPy arrays, and about array-based operations
Dictionary and Xarray Data Arrays
Organizing Data with Dictionaries
Key-Value Mappings and Summary Statistics
Creating Xarray DataArrays
Store Multiple Arrays Together with Information About Their Relationships
Building a Dataset Using XArray
Building a Dataset of DataArrays
Tabular Data
Pandas DataFrames
How to create and work with Pandas DataFrames
Groupby Operations: Applying Aggregations to Groups of Data
Analyzing by subgroups using groupby, visualizing group statistics with Seaborn
Task Performance Analysis with Pandas and Seaborn
Use Pandas DataFrames and Seaborn to analyze and visualize task performance
Reorganizing Data in DataFrames
Reorganize DataFrames using concatenation, merging, and melting operations
Data Visualization
Generating Signals with Scipy and Plotting with Matplotlib
How to generate sinusoids, boxcar, chirp, and sawtooth signals and visualize them
Image Data with Numpy and Matplotlib
Accessing and visualizing image data
Spike Time Analysis with Pandas and Matplotlib
Create raster and firing rate plots, use pandas methods to select data
ERP Analysis With Pandas And Seaborn
Visualize and analyze LFP data across brain regions using Seaborn