Python

I had never used Python before, all I learned was completely new and interesting! I really enjoyed the session and I will definitely sign up for the more advanced Python sessions organized by the Digital Skills Lab!

 

Python is an easy to learn, general purpose programming language that has developed into one of the most popular programming languages since its first release in 1991 and is now widely used by companies such as Google, Facebook, Instagram, Spotify, Reddit, Netflix, Amazon and Uber. 

Python is not only easy to learn, but also simple to use and easy to read which enables you to write code faster and collaborate more effortlessly. It is one of the prime choices for data science and artificial intelligence as it features a rich pool of libraries to transform, visualize and analyse data and is used in technology, finance, healthcare, retail, and ecommerce for those purposes. 

The Digital Skills Lab  is currently running the following series of Python workshops: 

  • Python Fundamentals (9 part series) 
  • Working with Tabular Data in Python (5 part series) 
  • Data Visualization in Python (3 part series)

Workshops will take place online and in person throughout the year. Click on the links below to book your place or express an interest so that you are notified as soon as workshops are available to book. 

Please note that the content for the online and in-person workshops are the same. Unless (online) shows up in the workshop booking link, the session will take place on campus in LRB.R.08 in the lower ground floor of the Library following current government guidelines, i.e. masks and social distancing measures will be in place to stop the spread of coronavirus. If you are booking an online workshop please make sure you meet the technical requirements

We have also curated some self-study courses that can be accessed via our Moodle page.  

If you can't find what you're looking for below, please email digital.skills.lab@lse.ac.uk or attend one of our drop-in sessions for advice. 

We also have workshops and self-study courses in R. See below if you're not sure which is right for you. 

Python vs R: Which is right for you? 

R is another very popular programme language for data science and both have their pros and cons without there being a clear winner. Python is easier to integrate with other software and is more versatile. Python is the better choice when it comes to web applications, software development, task automation and integration of analysis with web applications and production databases. The R analysis ecosystem is superior and provides a much larger number of libraries specialized in different types of statistical analysis and its ggplot library is still the gold standard when it comes to data visualization.  

  • Programming experience: Python and R are both easy to learn with many online resources available to continue to learn independently. If you already know another object-oriented programming language Python might feel more natural to you. 

  • Your environment: Which programming language do your peers, fellow students or teachers use? What is more common in your field of study? Do future employers or job sectors that you might target after graduation have a preference? 

  • Your goals: Some models and visualizations might be better supported in R than Python. Also consider your long-term career goals. If you aspire to become a software developer, you might prefer Python. 

Python Fundamentals

The Python fundamentals series teaches you the basic Python skills that form the foundation for any type of programming project. After having completed this series, you will be familiar with the Python syntax, know about the fundamental built-in functions and objects in Python and will be able to solve basic programming problems independently. This series of workshops  is ideal for those with NO prior experience of programming and is a prerequisite for the Working with Tabular Data in Python series. 

Python Fundamentals 1: Numerical Variables  (Workshop)

(formerly Python  1: Numerical Variables) 

In this workshop, you will learn the basics of working with numerical variables in Python. 

By the end of this session you will be able to:

  • Carry out calculations using the print function
  • Use numerical variables to carry out calculations 

Click on the link below to check availability and book your place:  

Python Fundamentals 1: Numerical Variables 

Python Fundamentals 1: Numerical Variables (online) 

Python Fundamentals 2: String Variables (Workshop)

(formerly Python 2: String Variables) 

In this workshop, you will learn the basics of working with string variables in Python.

By the end of this session you will be able to:

  • combine and replicate strings
  • use variables to represent strings
  • combine and replicate strings using string variables
  • use the input function to get user input in string format

Click on the link below to check availability and book your place: 

Python Fundamentals 2: String Variables 

Python Fundamentals 2: String Variables (online) 

 

Python Fundamentals 3: Converting Data Types (Workshop)

(formerly Python 3: Converting Data Types)

In this workshop, you will learn how to use functions to convert between different data types. 

By the end of this session you will be able to: 

  • Create and apply Booleans to represent true and false values
  • Convert between string, integer, float and Booleans

Click on the link below to check availability and book your place: 

Python Fundamentals 3: Converting Data Types 

Python Fundamentals 3: Converting Data Types (online) 

Python Fundamentals 4: Lists (Workshop)

(formerly Python 4a: Lists) 

In this workshop, you will learn to work with lists in Python. 

By the end of this session you will be able to:

  • Create a list
  • Select single elements from a list
  • Select a range of elements from a list

Click on the link below to check availability and book your place: 

Python Fundamentals 4: Lists 

Python Fundamentals 4: Lists (online) 

Python Fundamentals 5: List of lists (Workshop)

(formerly Python 4b: List of lists)

In this workshop, you will learn to work with a list composed of lists in Python.

By the end of this session you will be able to:

  • Create a list of lists
  • Select elements from a list of lists
  • Adding, removing and changing elements of a list

Click on the link below to check availability and book your place: 

Python Fundamentals 5: List of lists 

Python Fundamentals 5: List of lists (online) 

Python Fundamentals 6: Functions and Modules (Workshop)

(formerly Python 5: Functions and Modules)

In this workshop, you will learn how to use functions and modules in Python.

By the end of this session you will be able to: 

  • Use some of the most useful built-in Python functions 

  • Use string methods to manipulate and work with strings 

  • Use list methods to manipulate and work with lists 

  • Explain what a module is 

  • Import a module and use it functions 

Click on the link below to check availability and book your place 

Python Fundamentals 6: Functions and Modules 

Python Fundamentals 6: Functions and Modules (online) 

Python Fundamentals 7: For loops (Workshop)

For loops can help you to write more concise ane readible code by applying, for instance, a function to all elements from a list or another collection with a few lines of code. You can, for instance, use a for loop to go through all elements in a large list of emails to filter out only those that belong to a certain domain with only 3 lines.

Click on the link below to check availability and book your place 

Python Fundamentals 7: For loops 

Python Fundamentals 7: For loops (online)  

Python Fundamentals 8: Conditionals (Workshop)

In this workshop you will learn how with conditionals, you can compare values and control the flow of your program. You can use them to only select specific values from your data or to carry out different code depending on the type of data.

By the end of this session you will be able to: 

  • use logical operators to make comparisons
  • use if-else statements to control the flow of your code
  • combine for loops with if-else
  • use boolean operators to combine conditional expressions

Click on the link below to check availability and book your place: 

Python Fundamentals 8: Conditionals 

Python Fundamentals 8: Conditionals (online) 

Python Fundamentals 9: Writing functions

In this workshop you will learn how functions can help you to write better code, about the main elements of functions in Python, and how to write your own functions.

By the end of this session you will be able to: 

  • write your own functions to save keystrokes
  • make your code easier to read
  • improve the overall structure of your scripts

Click on the link below to check availability and book your place: 

Python Fundamentals 9: Writing functions 

Python Fundamentals 9: Writing functions (online) 

 

Working with Tabular Data

The Working with Tabular Data in Python series teaches you how to use the NumPy and Pandas libraries to work with datasets. After having completed this series, you will be able to use Numpy arrays to carry out arithmetic operations and to create subsets of arrays based on the numbers location or value inside the array. You will also learn how to use the Pandas library to import, inspect and prepare data for data analysis. This series is a prerequisite for the Data Visualization in Python series.

Working with Tabular Data 1: NumPy Arrays (Workshop)

(Formerly Python 6a: NumPy Arrays)

In this workshop, you will learn how to work with numPy arrays in Python.  

By the end of this session you will be able to: 

  • represent numerical values in arrays 
  • select elements from an array 
  • carry out calculations on arrays 
  • Use logical operators to create a subset of an array based on conditions 

Click on the link below to check availability and book your place: 

Working with Tabular Data 1: NumPy Arrays 

Working with Tabular Data 1: NumPy Arrays (online) 

Working with Tabular Data 2: NumPy 2D Arrays (Workshop)

(Formerly Python 6b: NumPy 2D Arrays)

In this workshop, you will learn how to work with 2-dimensional numpy arrays in Python. 

By the end of this session you will be able to: 

  • represent numerical values in 2D arrays
  • index and subset 2D arrays using logical expressions
  • carry out calculations using 2D arrays
  • calculate aggregate statistics

Click on the link below to check availability and book your place: 

Working with Tabular Data 2: NumPy 2D Arrays 

Working with Tabular Data 2: NumPy 2D Arrays (online) 

Working with Tabular Data 3: Pandas Basics (Workshop)

The pandas library is the most popular tool to work with tabular data. It is a very effective library for data cleaning, transformation and aggregation. In this workshop you will be introduced to how data is represent with the dataframe object in Pandas. 

By the end of this session you will be able to: 

  • create and use dictionaries
  • create a dataframe using a dictionary
  • import data from a csv file
  • explore a dataset
  • create frequency tables

Click on the link below to check availability and book your place: 

Working with Tabular Data 3: Pandas Basics 

Working with Tabular Data 3: Pandas Basics (online) 

Working with Tabular Data 4: Pandas Indexing (Workshop)

In this workshop you will learn the different techniques to create a subset of your data. Subsets are commonly used in statistical analysis and machine learning. For instance, you can use indexing to create a train and test set for your machine learning project.

By the end of this session you will be able to: 

  • select multiple columns
  • use .loc to create a slice of columns
  • use .iloc to select rows and columns based on position
  • use .loc to select based on the index

Click on the link below to check availability and book your place: 

Working with Tabular Data 4: Pandas Indexing 

Working with Tabular Data 4: Pandas Indexing (online)  

Working with Tabular Data 5: Pandas Data Exploring (Workshop)

In this workshop you will learn how to use boolean indexing to create subsets based on values in your dataset. You could, for instance, use subsets to create separate plots for male and female respondents.

By the end of this session you will be able to: 

  • Transform a dataset by calculating new columns
  • Create subsets using boolean indexing

Click on the link below to check availability and book your place: 

Working with Tabular Data 5: Pandas Data Exploring  

Working with Tabular Data 5: Pandas Data Exploring (online)  

 

Data Visualization in Python  

The Data Visualization in Python series teaches you how to use the most popular libraries to generate visualizations in Python. After having completed this series, you will be able to create and customize line, scatter, bar plots and histograms with matplotlib. You will also learn how to create visualizations with pandas and seaborn. Matplotlib is the original library written in Python for data visualization and seaborn and pandas plotting capabilities depend on matplotlib. While matplotlib is very powerful, it often requires more code to create visually pleasing and effective plots compared to seaborn or pandas.

Data Visualization in Python 1: Line Plots with Matplotlib

Matplotlib is the most popular library to generate plots in Python. It allows you to plot basically any type of plot with very few code. Although creating more complex plots, can be challenging, it isn't difficult to find useful help online. Since pandas and seaborn, which provide more user-friendly ways to create plots in Python, are based on matplotlib, it is important to first understand how to create and customize plots with matplotlib. 
 
In this session you will learn how to create line plots to visualize the change of a quantitative variable, e.g. stock prices or economic variables over time. 

By the end of this session you will know how to: 

  • import financial and economic data using the pandas-datareadercreate  
  • create line plots with matplotlib 
  • apply basic customizations to plots 
  • plot lines for multiple data series in the same plot 

Click on the link below to check availability and book your place: 

Data Visualization in Python 1: Line Plots with Matplotlib  

Data Visualization in Python 1: Line Plots with Matplotlib (online) 

Data Visualization in Python 2: Scatter, Bar Plots and Histograms with Matplotlib

This session teaches you how to create scatter and bar plots and histograms with matplotlib. Scatter plots can help you explore the relationship between two quantitative variables. You will also learn how to use histograms and bar plots to visualize the distribution of quantitative and qualitative variables respectively. 

By the end of this session you will know how to: 

  • create scatter plots to visualize the relationship between two or three quantitative variables 
  • create and customize histograms 
  • prepare data to create bar plots 
  • create and customize bar plots 

Click on the link below to check availability and book your place: 

Data Visualization in Python 2: Scatter, Bar Plots and Histograms with Matplotlib  

Data Visualization in Python 2: Scatter, Bar Plots and Histograms with Matplotlib (online) 

Data Visualization in Python 3: Plotting with Pandas and Seaborn (Workshop)

This session will introduce you to using pandas and seaborn to create plots. Pandas, through its dataframe plotting methods, provides a very efficient way to create basic plots. Seaborn is a separate library that enables you to create complex and visually pleasing plots more easily than with matplotlib. 

By the end of this session you will know how to:  

  • create bar plots and histograms with pandas 
  • create a histogram matrix with pandas 
  • create a heatmap with seaborn 
  • create line plots with seaborn 

Click on the link below to check availability and book your place: 

Data Visualization in Python 3: Plotting with Pandas and Seaborn  

Data Visualization in Python 3: Plotting with Pandas and Seaborn (online) 

 

The Python training series is a meaningful task based introduction to Python coding language. The instructors provide guidance when needed throughout the independent partnered learning experience. Very grateful for this resource!

Laura Stahl, Department of Anthropology