Data Collection
Data collection is the systematic gathering of data relevant to the defined problem. It is the second step of the analytics process, and every downstream result inherits its quality — biased or incomplete collection cannot be repaired by clever modelling later.
Primary vs Secondary Data
| Basis | Primary Data | Secondary Data |
|---|---|---|
| Definition | Collected first-hand for the current study | Collected earlier by someone else, for another purpose |
| Originality | Original | Already existing |
| Cost | High | Low or free |
| Time required | Long | Short |
| Control over quality | Full control | No control |
| Relevance to problem | Exactly tailored | May only partly fit |
| Reliability | High (if method is sound) | Depends on the original collector |
| Examples | Your own survey, lab experiment, sensor logs | Census reports, RBI data, Kaggle datasets, competitor annual reports |
Primary Data Collection Methods
| Method | Description | Best for | Limitations |
|---|---|---|---|
| Survey / Questionnaire | Structured set of questions to many respondents (online, paper, phone) | Large samples, quantifiable opinions | Low response rate, response bias |
| Interview | One-to-one questioning — structured, semi-structured or unstructured | Depth, exploring "why" | Expensive, time-consuming, interviewer bias |
| Observation | Recording behaviour without asking (participant or non-participant) | Actual behaviour vs claimed behaviour | Cannot observe motives; observer effect |
| Experiment | Controlled manipulation of a variable with a control group (A/B tests) | Establishing causation | Costly, ethical constraints, artificial settings |
| Focus group | Moderated group discussion (6–12 people) | Idea generation, qualitative themes | Dominant voices skew results |
| Sensors / IoT / logs | Automatic machine capture | Continuous, high-volume, objective data | Storage cost, noise, calibration drift |
Questionnaire Design — Key Rules
- Keep questions short, simple and unambiguous.
- Avoid leading questions — "Don't you agree our service is excellent?" ✗
- Avoid double-barrelled questions — "Was the food tasty and affordable?" ✗ (two questions in one)
- Use consistent scales (e.g. a 5-point Likert scale: Strongly Disagree → Strongly Agree).
- Put sensitive/demographic questions at the end.
- Mix closed-ended (easy to quantify) and a few open-ended (rich detail) questions.
- Pilot test on a small group before full rollout.
Secondary Data Sources
| Source type | Examples |
|---|---|
| Government / official | Census of India, data.gov.in, RBI, NSSO, World Bank, WHO |
| Organisational records | Sales databases, CRM, ERP, transaction logs, web analytics |
| Commercial providers | Nielsen, Bloomberg, market-research firms |
| Academic | Journals, conference papers, university repositories |
| Open data platforms | Kaggle, UCI Machine Learning Repository, Google Dataset Search |
| Web | APIs (Twitter/X, YouTube), web scraping, RSS feeds |
Always evaluate secondary data before trusting it: Who collected it? When? For what purpose? What was the sample? What definitions were used? Has it been revised?
Data Collection in Practice — Python
import pandas as pd
# 1. From a CSV file (most common secondary source)
# df = pd.read_csv("students.csv")
# 2. From an Excel workbook
# df = pd.read_excel("sales.xlsx", sheet_name="Q1")
# 3. From a public API (JSON response)
import requests
# resp = requests.get("https://api.example.com/v1/records")
# df = pd.json_normalize(resp.json()["data"])
# 4. From a SQL database
# import sqlite3
# conn = sqlite3.connect("college.db")
# df = pd.read_sql_query("SELECT roll, name, marks FROM students", conn)
# 5. From a web page table (simple scraping)
# tables = pd.read_html("https://en.wikipedia.org/wiki/List_of_Indian_states")
# df = tables[0]
# 6. Manually entered / survey export
survey = pd.DataFrame({
"respondent": [1, 2, 3, 4],
"age": [19, 21, 20, 22],
"satisfaction": [4, 5, 3, 5], # 5-point Likert
"would_recommend": ["Yes", "Yes", "No", "Yes"],
})
print(survey.describe())
Sources of Error in Data Collection
Sampling error shrinks as the sample grows. Non-sampling error does not — a badly worded question asked of a million people is still badly worded. This is why collection design matters more than sheer volume.
Ethical and Legal Considerations
| Principle | Meaning |
|---|---|
| Informed consent | Respondents know what is collected and why |
| Privacy | Personally identifiable information (PII) protected and minimised |
| Anonymisation | Remove or hash identifiers before analysis |
| Purpose limitation | Use data only for the stated purpose |
| Data security | Encrypt at rest and in transit; restrict access |
| Regulatory compliance | GDPR (EU), India's DPDP Act 2023, HIPAA (health, US) |
| Right to withdraw | Respondents can opt out and request deletion |
Once data is collected, the immediate question is how much and which subset to analyse — the topic of the next lesson, sampling.