Data · Code · Interpretation

Introduction to Data Science

How do we turn data into a researchable question, a checkable analysis, and a conclusion we can explain?

This course is being built. Only some of the units are published; the rest are marked ‘in preparation’. What is published is complete and can be studied now.

Learning materials and visual explanations

  1. Databases: SQL and ORM

    Available

    Store, query, and change data with SQL (a language for databases), then connect tables to Python objects with an ORM (object-relational mapper).

    1. 2.1LessonA Practical SQL Guide with DB Browser, Part 1: Retrieve and AnalyzeOpen a real bike-share database in DB Browser, then retrieve, filter, sort, summarize and group rows to see when demand is highest.
    2. 2.2LessonA Practical SQL Guide with DB Browser, Part 2: Change Data and Combine TablesChange data safely, combine tables with JOIN, export results, and use the whole toolbox to answer the bike-share capacity question.
      Practice pages (5)
      1. 2.2.1ExerciseSQL Practice: Review and Back to the Practical Question (Bike Rides)Review the whole toolbox of the SQL guide on the bike-share database, then answer the practical question: when does a bike-share system need capacity?
      2. 2.2.2ExerciseSQL Practice: Two Tables, One Key (Weather and Bike Rides)Practice JOIN on a small two-table database: a table of days that holds a number, and a lookup table that says what the number means. Show, filter and average by the name, not by the number.
      3. 2.2.3ExerciseSQL Practice: Where New Immigrants Settled in IsraelPractice SELECT, JOIN, GROUP BY, HAVING and NULL on open government data about new immigrants and the localities that absorbed them, and learn to check a table before trusting a total.
      4. 2.2.4ExerciseSQL Practice: S&P 500 Companies and Their FilingsPractice SELECT, GROUP BY, HAVING, and UPDATE on real company data, and learn to check whether a number is believable before using it.
      5. 2.2.5ExerciseSQL Exercises: A Question GeneratorPractice SQL on as many questions as you like: write a query in the browser, get it checked, and learn from feedback on what is wrong.
    3. 2.3LessonThe minimum Python for working with SQLiteThe Python that a first program needs in order to ask a SQLite database a question: values and text, tuples, connect, cursor, execute and fetch, parameters, functions that query, and max with a key.
    4. 2.4LessonPython for Databases 1: Values, Variables and CollectionsHow Python holds one row and a whole table of bike-share data: values, variables, text, lists, tuples and dictionaries, the first step before using SQL from Python.
    5. 2.5LessonPython for Databases 2: Loops and FunctionsHow a Python program goes over the rows of a table, decides about each one, and packs a piece of work into a function with parameters and a sorting key.
    6. 2.6LessonPython for Databases 3: Objects and Generator ExpressionsA minimal class turns a table row into an object, and a generator expression asks a question about many objects in one line: the two ideas behind object-relational mapping.
    7. 2.7LessonSQL from Python: Queries, Parameters and Saving ChangesSend SQL queries to a SQLite database from a Python program with the sqlite3 module: connect, execute, fetch rows, pass values safely with parameters, and save or cancel changes.
    8. 2.8LessonTables as Python Objects: A First Look at Pony ORMDescribe a database table as a Python class, add, read, summarize, change and delete rows as objects, and let Pony ORM write the SQL from a generator expression.
    9. 2.9LessonPony ORM Relations: A Table That Points to Another TableConnect two tables that point to each other as Python classes with Pony ORM, follow the relation in both directions, read the SQL that runs, and load related rows from a CSV file, with real World Bank data.
  2. Data Collection: Web Crawling and APIs

    Available

    Collect data from the web by reading pages and calling APIs (interfaces through which a service shares data with programs).

    1. 3.1LessonFrom a Web Page to Data: Beautiful SoupRequest a real web page with Python, see how its tags are organized, and use Beautiful Soup to find one element of a real arXiv page and read its text and its link.
    2. 3.2LessonFrom One Element to All Entries: find_all, Numbers and Missing ValuesRead every entry of a real arXiv list with Beautiful Soup: find_all and a list comprehension, the number of authors of each paper, the maximum and the mean, text that becomes a number, and entries that do not have a value.
    3. 3.3LessonSelf-studyFrom a List to Many Pages: Following LinksFollow the links of a real arXiv list to the page of each paper, read attributes of meta tags, turn text such as 3,330 KB into numbers, handle a missing element, and compute the maximum and the mean over the scraped values.
    4. 3.4LessonPatterns in Text: Regular ExpressionsFind numbers, identifiers, dates and codes inside the text of real arXiv pages with Python regular expressions: raw strings, re.search and re.findall, character classes, quantifiers, groups and the shortest match, and when Beautiful Soup is the better tool.
      Practice pages (1)
      1. 3.4.1ExerciseRegular Expression Lab: Practice on Real arXiv TextA lab for regular expressions: type a pattern, see what it fits in real text from arXiv, and read an explanation of every part of the pattern. Five challenges on the numbers of pages, identifiers, sizes, dates and subject codes.
    5. 3.5LessonAsking a Service for Data: an API and JSONAsk the Wikipedia API about real hardware pages with requests: an endpoint and parameters, the status code, a user agent, an answer in JSON, nested dictionaries and lists, and a key that is missing.
  3. Tabular Analysis and Large Data

    In preparation

    Analyze tables with NumPy and pandas, and work with data that is too large to handle in one piece.

  4. Static and Interactive Visualization

    In preparation

    Choose, build, and read charts, from fixed figures to charts you can explore.

  5. Networks and Graph Mining

    In preparation

    Networks of nodes and edges: which nodes matter most, how communities form, and what can be learned from the structure.

  6. Text Analysis

    In preparation

    Text as data: word counts, TF-IDF (which words characterize a document), topic discovery, and named entities.

For the whole course

These materials supplement the teaching in the course. The syllabus, deadlines, assessment instructions, and group announcements are published in the institution’s course system.