Course overviewGoogle Search · Prepare text and combine files
Load and combine daily files
Read two CSV extracts, append their rows, and export without an index column.
Step 1 of 3 · Learn
Read CSV text into a DataFrame
Import StringIO from io, then use pd.read_csv(StringIO(csv_text)). StringIO makes the supplied text readable like a file. read_csv uses its first line as column names and infers types; it is not a reliable schema validator.
index
id
value
0
1
10
1
2
20
↓
index
id
value
0
1
10
1
2
20
The CSV header becomes the column names; its data lines become rows.
Append compatible inputs
pd.concat([first, second], ignore_index=True) stacks rows in the supplied order and resets the index. Columns align by name, not position. Mismatched schemas can create extra columns and missing cells, so check them before combining.
df
index
id
value
0
1
A
1
2
B
next_day
index
id
value
0
3
C
1
4
D
↓
index
id
value
0
1
A
1
2
B
2
3
C
3
4
D
Append the second input below the first and build a fresh 0-based index.
Export data, not the index
combined.to_csv(index=False) returns CSV text when no path is supplied. The header is included; index=False omits index labels. Pandas quotes commas and quotation marks as needed. Save this returned string as result for the export task.
▷ Your turn
Read day_one_csv and return its DataFrame with columns search_id, query, device, and response_ms in that order. Preserve CSV row order and use the default 0-based index. Save it as result.
day_one_csv and day_two_csv contain CSV text for the first three searches from each of the first two dataset dates. Both have search_id, query, device, and response_ms headers. These are small daily extracts, not full-day totals. Use StringIO to read them in memory; no download or local file access is needed.