Question
Use the month_name() function instead of month to show the month names instead of the month numbers in python Sample data purchase_date product_type 01/01/2020 Canvas
Use the month_name() function instead of month to show the month names instead of the month numbers in python
Sample data
purchase_date | product_type |
01/01/2020 | Canvas Painting |
02/01/2020 | Framed Poster |
03/01/2020 | Framed Poster |
04/01/2020 | Framed Poster |
05/01/2020 | Canvas Painting |
06/01/2020 | Poster Print |
07/01/2020 | Framed Poster |
08/01/2020 | Framed Poster |
09/01/2020 | Canvas Painting |
10/01/2020 | Framed Poster |
My code isn't working
import pandas as pd
import numpy as np
from datetime import datetime
df = pd.read_csv('sales.csv')
df['month'] = pd.DatetimeIndex(df['purchase_date']).month_name()
df['month'].value_counts()
print(df.month_name.value_counts())
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started