Python Forum
Monthly sales, standard deviation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Monthly sales, standard deviation
#4
Right, makes sense. It's just tough to make a concise example b/c the data is so lengthy.

I did some more experimenting and I've figured out what's going on. Resample() will interpolate, but not extrapolate. So if I have sales of an Item in Jan and Dec, I will get 12 values, even if there is zero sales in Feb-thru-Nov. If I have sales in Mar and Jun only, but none in Jan-Feb or Jul-Dec, I will get 4 values (Mar, Apr, May, Jun).

So, because I have sales of something in every month of the year, my solution was to unstack() the dataframe after the resample(). That forced the resampled 12 months along the top as columns with a ton of NaN's. I filled the NaN's with zeros, then stack(), and presto, 12 values for every item.

Seems a little kludgy, maybe there's a better way?
Reply


Messages In This Thread
Monthly sales, standard deviation - by Lyle - Jul-31-2020, 04:35 PM
RE: Monthly sales, standard deviation - by Lyle - Aug-07-2020, 05:10 PM
RE: Monthly sales, standard deviation - by Lyle - Aug-07-2020, 10:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Resample from monthly to weekly works, but not vice versa JaneTan 0 691 Dec-14-2022, 12:58 AM
Last Post: JaneTan
  Winsorized Mean and Standard Deviation Wheeliam 0 1,908 Jul-11-2020, 05:27 PM
Last Post: Wheeliam
  standard library modules chpyel 4 2,988 May-10-2020, 02:58 PM
Last Post: snippsat
  plot multiple employee sales data in a single graph pitanshu 0 1,986 Oct-24-2019, 01:56 PM
Last Post: pitanshu
  Is there a standard for autocommit In PEP 249 zatlas1 10 5,589 Feb-06-2019, 04:56 PM
Last Post: buran
  Graphics and standard deviation rocioaraneda 3 2,872 Jan-09-2019, 10:53 PM
Last Post: micseydel
  How to calculate variance(standard deviation) by column SriRajesh 2 2,943 Dec-27-2018, 12:35 PM
Last Post: SriRajesh
  standard data types rombertus 3 86,028 Dec-23-2018, 08:52 PM
Last Post: rombertus
  Create a monthly mean column in multiple years fyec 1 4,154 Jun-21-2018, 03:57 AM
Last Post: scidam
  Standard library code BerryK 2 4,144 Apr-29-2017, 10:32 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020