-2

Beginner question. I'm trying to analyse some data from a Trello. I've pulled in the full csv and made a new data frame df2 with three columns: 'Task Name', 'Created Date' and 'Description'.

Example df(sorry, can't share the csv as it's work data):

Task Names Created Date Description

Lorum ipsum 14/05/2020 Lorum ipsum

Lorum ipsum 13/05/2020 Lorum ipsum

Lorum ipsum 18/04/2020 Lorum ipsum

I want to create a graph of the number of tasks created each month. I've been able to do that with the below but the x-axis ticks display numbers, I'd like them to display month names. Is that possible?

df = pd.read_csv('XXX')
df2 = df[['Task Name', 'Created Date', 'Description']].copy()

df2['date_time'] = pd.to_datetime(df2['Created Date'], format='%d/%m/%Y')

df2.groupby(df2['date_time'].dt.month).size().plot(kind='bar')

Thanks!

  • 1
    Does this answer your question? [Pandas timeseries plot setting x-axis major and minor ticks and labels](https://stackoverflow.com/questions/12945971/pandas-timeseries-plot-setting-x-axis-major-and-minor-ticks-and-labels) – Jack Henahan May 24 '20 at 20:18
  • Thanks for the reply! I don't think so, though I could be reading it wrong. my dataset could have multiple instances in a month, which need grouping into one data point on the table (so in the example above there are two tasks in May, so May would be 2), which, from playing with it, i don't think the other question allows. – ElCrouchoGrande May 25 '20 at 14:13

1 Answers1

0

I managed to fix using the 'month_name' DateTime function. Turns the month number to the month name, so no need to play with the x-ticks.

df = pd.read_csv('XXX')

df2 = df[['Task Name', 'Created Date', 'Description']].copy()

df2['Month Created'] = df2['Created Date'].dt.month_name()

df2['Month Created'].value_counts().plot(kind='bar')