LearnPy Hub
← Pandas: Cleaning & Preprocessing problems
Easy

Add a Month Column

Convert the date column with pd.to_datetime, add month = df['date'].dt.month and print each month amount.

Input

Lines 'date region product amount', then END.

Output

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
1 500
1 300
2 1200
2 450
3 800
3 650

Sample 2

Input
2026-05-01 Dhaka Tea 100
END
Output
5 100
solution.py
Output appears here
Add a Month Column · Python practice problem · LearnPy Hub