Medium
One-Hot Encode the Region
Use
pd.get_dummies(df['region'], dtype=int) to one-hot encode the region. Print the new column names on one line, then the sum of each column on the next line (how many rows each region has).Input
Lines 'date region product amount', then END.
Output
Two lines.
Sample 1
Input
2026-01-15 Dhaka Tea 500 2026-01-20 Sylhet Tea 300 2026-02-03 Dhaka Rice 1200 2026-02-18 Khulna Tea 450 2026-03-07 Sylhet Rice 800 2026-03-21 Dhaka Tea 650 END
Output
Dhaka Khulna Sylhet 3 1 2
Sample 2
Input
2026-05-01 Dhaka Tea 100 END
Output
Dhaka 1
Output appears here