Introduction to Python

An undergraduate course introducing Python programming for data analysis, with applications in social science and communication research.

Instructor Zhicong Chen
Term Spring 2024
Location Nanjing University

Course Overview

This course gives undergraduate students a practical foundation in Python programming, with a focus on data analysis tasks common in journalism, communication, and social science research. No prior programming experience is required.

Learning Objectives

By the end of this course, students will be able to:

  • Write clean, readable Python scripts and Jupyter notebooks
  • Load, clean, and transform tabular data with pandas
  • Produce publication-quality charts with matplotlib and seaborn
  • Collect data from web APIs and perform basic web scraping
  • Complete an end-to-end data analysis project independently

Prerequisites

No prior programming experience required. Familiarity with spreadsheets (Excel / Google Sheets) is helpful but not mandatory.

Level

Undergraduate

Institution

School of Journalism and Communication, Nanjing University

Offered

Spring 2024

Required Textbook

McKinney, W. (2022). Python for Data Analysis, 3rd ed. — freely available online. O’Reilly.

Key Tools

Tool Purpose Link
Python 3 Core language python.org
Jupyter Notebook Interactive coding environment jupyter.org
Google Colab Cloud-based Jupyter (no setup) colab.research.google.com
pandas Data manipulation pandas.pydata.org
NumPy Numerical computing numpy.org
matplotlib Plotting matplotlib.org
seaborn Statistical visualisation seaborn.pydata.org
Requests + BeautifulSoup Web scraping requests
Anaconda All-in-one installer anaconda.com

Assessment

Component Weight
Weekly coding exercises 40%
Midterm project 20%
Final data analysis project 35%
Participation 5%

Schedule

Week Date Topic Materials
1 Week 1 Getting Started: Python & Jupyter

Course overview, installing Python, working with Jupyter notebooks, basic syntax and data types.

2 Week 2 Variables, Types, and Operators

Numbers, strings, booleans, type conversion, arithmetic and comparison operators.

3 Week 3 Data Structures: Lists, Dicts, Sets

Choosing the right container; indexing, slicing, and mutability.

4 Week 4 Control Flow: Conditionals and Loops

if/elif/else, for loops, while loops, list comprehensions.

5 Week 5 Functions and Modules

Defining functions, arguments, return values, scope, importing standard-library modules.

6 Week 6 Working with Files and the OS

Reading/writing text and CSV files, pathlib, os.path.

7 Week 7 NumPy: Numerical Computing

Arrays, vectorised operations, broadcasting, random number generation.

8 Week 8 pandas: Data Manipulation

DataFrames, Series, loading CSV/Excel, filtering, groupby, merging.

9 Week 9 Data Cleaning and Transformation

Handling missing values, duplicates, type casting, string operations, apply().

10 Week 10 Visualization with matplotlib & seaborn

Line plots, bar charts, scatter plots, histograms, heatmaps, and style customisation.

11 Week 11 Fetching Data: APIs and Web Scraping

HTTP requests with requests library, parsing HTML with BeautifulSoup, working with JSON.

12 Week 12 Mini-Project Presentations

Students present end-to-end data analyses of a self-chosen social or communication topic.