Data Science ยท Chapter 4 of 43

Data Collection

Data comes from DATABASES (SQL), APIs (REST/GraphQL), FILES (CSV/Excel), WEB SCRAPING and SENSORS/LOGS.

Document the source, license and refresh cadence for every dataset you use.

Example 1 (python)
import pandas as pd
df = pd.read_csv('sales.csv')
print(df.head())

Read a CSV file.

Example 2 (python)
import requests
r = requests.get('https://api.example.com/users')
data = r.json()

Pull from a REST API.

Key points

  • Sources: DB, API, files, scraping, sensors.
  • Always record where data came from.
  • Check licence and privacy rules.
  • Refresh cadence matters for freshness.
๐Ÿ’ก Note: Save the raw file untouched โ€” do all cleaning downstream so you can always re-do the pipeline.

๐Ÿ“ Quick Quiz

1. pd.read_csv reads:

2. REST APIs commonly return:

3. Raw data should be: