-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
Description
I have a Dataframe with a DatetimeIndex spanning more than one day (freq=1D
).
From this DataFrame i extract a subset with groupby (--> leads to a Dataframe with freq=None
)
When I plot these DataFrames, the xaxis (DateTimeIndex) is fromatted in two different ways. If freq is specified (freq=1D
) the xaxis-ticks look like I desire it.
But the Dataframe with freq=None
the xaxis shows only timestamps without day, month or year (because the Timerange is more than one day some ticks are doubled..and so its confusing and hard to read)
It would be fine if the xaxis-Ticks would be formatted the same way (show year, month and day)
My code:
import os
mport sys
import datetime
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.dates as mdates
import numpy as np
%matplotlib notebook
dates = pd.date_range('2013-07-14 11:00:00', '2013-07-16 11:00:00', freq = 's')
cats = np.random.choice(['m', 'f', 'c'], len(dates))
data =np.random.randn(len(dates),1)
data2 =np.random.randn(len(dates),1)
df = pd.DataFrame(data, dates)
df.columns = ['data']
df['cats']= cats
df['data2'] = data2
df.plot()
data_grouped = df.groupby('cats')
df2 = pd.DataFrame(data_grouped.get_group('m'))
df2.plot()
Pandas Version
pd.__version__
'0.18.0rc1'