Problems with .resample('M') - resampling

I am using pandas & I have a dataframe with Date, Item#, Qty and 12 months of sales data. I want to do a std dev calc to understand the monthly variability for each Item#.
The problem is for many Item#'s the sales are sporadic: I may only sell Item XYZ in Feb and Mar, and zero the rest of the months of the year.
I am using this code to do the heavy lifting:
df.groupby('Item#').resample('M').sum()
For some Item#'s it is forcing zeros into the empty months (GOOD!), but in many cases it is just showing, say, two months of data, instead of 12, which then makes the std dev calculation incorrect.
Can someone help me understand why this behaviour of the .resample method? How can I workaround this problem?
Many thanks in advance for your help!

Related

Attendance tracker: Only count days Absent, Present, Late etc.. from previous days till present

I have a google sheet that I use an attendance tracker for our business. This sheet reads month tabs and tally's the total Days present, Absent, Late etc..
The issue I am running into is that when someone plans a future time off or prearrange lateness I don't want it to tally that until it becomes the present day.
Essentially it should only tally up the present day and the past.
Thanks for the help.
In the "Report 2022" tab it shows Employee 15 having 6 Present days and 2 AR days. That totals to 8 "Working days count" , thats not accurate because the 2 AR days didnt happen yet; they are future dates.
If you look in the November tab it is counting the AR for future dates, I only want it to count past and present.
I haven't really came up with an idea, I tried the today function but I don't know exactly the best way to go about it.
Here is the sheet with Dummy employee data: https://docs.google.com/spreadsheets/d/103srHeFcJXvVKNn3w4ljuxAbnpMMy3YNHS4EJthx1pw/edit?usp=sharing

Combining year-month data to continuous month variable (lubridate)

ExampleI've got the following dataset year-month variable going from 1995 to 1999 and months 1 to 12.
The months start at 1 again at each new year. I want to create a continous month variable from 1 to 60, i can't find the correce lubridate code for this, any suggestions?
Much appreciated,
Best regards, Joris

Next 6 months Data In OBIEE

I want to display Next 6 months Data from Current Month in OBIEE 11g.I tried with addmonths() but it shows all years in data,and if i filter on current year it will not shows months in next year.
It all depends - and that why someone voted down your question; it's just not very precise.
What do you want to compare it with? A month number? A month name?
Do you have what's needed? Do you have a properly formed time dimension?
The unclean approach is to use TIMESTAMPADD butwith that you're just curing the symptom, not the root cause.
TIMESTAMPADD(SQL_TSI_MONTH, 6, NOW())

Can I generate the number of business days in a month in Visual Studio?

I have a report that takes sales data from a few tables. I want to add a field that will divide the total sales for the given month by the total number of business days in that same month. Is there a way I can calculate that in an expression? Do I need to create a new table in the database specifically for months and their number of business days? How should I go about this?
Thank you
Intuitively, I would say that you need a simple function and a table.
The table is to host the exceptions like Independence day, labor day, etc.
The function will get two parameters: Month and Year (I'm not providing any sample code since you haven't specified which language you are using).
It will then build a date as yyyy-mm-01 (meaning, first day of the month). If will then loop from 2 to 31 and:
Create a new date by adding the index of the loop to the initial date,
Check if the resulting date is still within the month,
Check if it is a working or not working day (e.g. Sunday),
Check if it is found within the table of exceptions.
If the created date passes all the above tests, you add 1 to the counter.
Though it might look complex, it is not and it will provide you the correct answer regardless of the month (e.g. Feb.) and the year (leap or not).

Group days in Business Objects?

I'm trying to group StartDateTime in Business Objects. Data for StartDateTime is coming from a Cisco server. It is in format 7/15/2013 10:52 AM. I am just trying to group these so it's 7/1, 7/2, etc.
I need to create a dimension out of this Day Grouping so I can represent a count of events on each date. Right now I am doing:
=FormatDate([Query 1 (1)].[Startdatetime];"DD")
I've tried variations of this, but nothing is working. I used the above formula to group the hours, I just replaced "DD" with "HH", so not sure why this formula would be so different.
Any ideas? Thank you. It's appreciated.
what if you try
=FormatDate([Query 1 (1)].[Startdatetime];"dd/MM/yyyy")
This is old but wasn't answered. In case anyone stumbles upon this like I just did, the formula is just case sensitive. It should be:
=FormatDate([Query 1 (1)].[Startdatetime];"MM/dd")
Here's a link that includes all permutations of date formatting:
https://blogs.sap.com/2013/11/21/how-to-use-formulae-to-change-date-and-time-formats-in-webintelligence/

Resources