Gaussian kernel density smoothing for pandas.DataFrame.resample?
I use pandas.DataFrame.resample
to reprogram random events to 1 hour intervals and see very stochastic results that don't seem to disappear if I increase the interval to 2 or 4 hours. This leaves me wondering if Pandas has a method of any kind for creating a smoothed density kernel, such as the Gaussian kernel density method, with an adjustable bandwidth to control the antialiasing. I don't see anything in the documentation, but thought I'd post here before posting to the developers server as that is their preference. Scikit-Learn has exactly the Gaussian kernel density function I want , so I'll try to use it, but it would be a fantastic addition to Pandas.
Any help is greatly appreciated!
hourly[0][344:468].plot()
source to share
Pandas has the ability to apply rolling window aggregation. The parameter win_type
controls the shape of the window. The parameter center
can be set so that the labels are set in the center of the window instead of the right edge. To do Gaussian smoothing:
hrly = pd.Series(hourly[0][344:468])
smooth = hrly.rolling(window=5, win_type='gaussian', center=True).mean(std=0.5)
http://pandas.pydata.org/pandas-docs/stable/computation.html#rolling
source to share