Find the average windspeed in January for each location - pandas-groupby

find mean of each location in the January month from 1968-1672
watch data for clear understanding:
https://github.com/prataplyf/Wind-DateTime/blob/master/wind_data.csv
year = wind.index.year.unique()
year
month = wind[(wind.index.year==wind.index.year.unique())]
month.mean()```
get 'mean()' of each location only Jan data
Output format
RPT VAL ...... ...... ..... ...... .... ....BEL MAL
1961-1
1962-1
1963-1
.
.
.
.
.
1672-1

Data.loc[(Data['Date'].dt.month==1)].mean()
try this

Related

Need to get output of all weekdays starting from given date

Output is not how it should be
given_day = datetime.date(2022,10,31)
dates = given_day + datetime.timedelta(days=+1)
for i in range(0 - given_day.weekday(), 7 - given_day.weekday()):
print(given_day.strftime("%A"))
Output should start from Monday and end to Sunday
Output I get is:
Monday
Monday
Monday
Monday
Monday
Monday
Monday
Where i made a mistake :(
I can't make head or tail of your code, but the following works:
given_day = datetime.date(2022,10,31)
for i in range(0 + given_day.weekday(), 7):
print(given_day.strftime("%A"))
given_day += datetime.timedelta(days=1)

PowerBI I need to calculate the datediff

in PowerBI I need to calculate the datediff between the date on the row to the maximum date possible on the table
Example
Table A ( this table has no id for each row)
Row . Date
1 . 1-jan-2000
2. 7-jan-2000
3. 8-jan-2000
4. 10-jan-2000
5. 31-jan-2000
What I am trying to get
Row . Date . Maximum Date in Table Calculated Column DateDiff (days)
1 . 1-jan-2000 . 31-jan-2000 30
2. 7-jan-2000 . 31-jan-2000 24
3. 8-jan-2000 . 31-jan-2000 23
4. 10-jan-2000 . 31-jan-2000 21
5. 31-jan-2000 . 31-jan-2000 0
I have tried to create a measure of the max date, and used last date, but when looking at the row it just gives the date as the current date of the row and not its max date of the table
every row should have the same maximum date, and i can then calculate the diff between the date on the row and the max date
I started with data given below -
Step 1:-
Make Sure your Date Column in the Table belongs to data type "Date".
Step 2:-
Create a calculated column using DAX then, with the DateDiff function
Date Diff = DATEDIFF(MyTable[Date],MAX(MyTable[Date]),DAY)
Here is a link to learn the DATEDIFF function.
The output looks like below :-
Kindly accept the answer if it works for you or let me know if it doesn't.

How to create a date in excel

I have excel file with 2 columns, year, and month. The year is given in YYYY format and the month the full name of the month like January, February.
Data sample,
column1, Column2
2014, January
2014, February
2018, March
As of now I have tried below code which is giving the error.
=date(A2, B2, 01)
and it is not returning any date values.
Requesting your assistance.
It will also work for me if it is solved by sas code.
Try:
=DATEVALUE(CONCATENATE(B3," 1, ",A3))
This will concatenate the month, follow by a 1 and the year (ex: January 1, 2014). It will then convert this to a datevalue (dates are stored as numbers in Excel). If you format your cell as a date (MMMM YYYY) you will have the desired result.
Try following
=DATEVALUE("1-" & LEFT(B1,3) & "-" & A1)
If you were importing the data into SAS, here is a solution to create a date from month name and year variables.
data have;
length month $ 15;
infile datalines delimiter=',';
input year month $;
datalines;
2014, January
2014, February
2018, March
;
Run;
Data want(keep=date);
Set Have;
/*Length mon $3 yr $4 dt $15;*/
/*Mon=substr(month,1,3);*/
/*Yr=put(year,4.);*/
/*Dt=cats('01',mon,yr);*/
/*Date = input(dt,date9.);*/
/* All in one line */
Date = input(cats('01',substr(month,1,3),put(year,4.)),date9.);
Format DATE mmddyy10.;
Run;

SLA COUNT IN EXCEL FORMULA

I'm looking for an excel (Office 2016 packet) formula that count SLA for ticket resolution.
the SLA counter must consider :
1) Monday To Saturday as work day ;
2) Holiday as no working days (must be skipeed as work day);
3) SLA start for ticket generate in workdays during range-time "08:00-20:00" out of this time-range SLA count is "0" ;
4) Output should result as R1= first 24Hours ; R2= from 25 to 48 hours ; R3= from 49 to 72 hours; "Out of Sla" = since 72 hours
Data to count SLA is formatted as below for either for ticket open and closure:
Column N Column O Column P Column Q
"TICKET START DATE" "TICKET STOP DATE" "SLA" "HOLIDAY"
28/4/18 13:30 30/4/18 19:20 2 25/04/2018
28/4/18 13:11 29/4/18 13:11 1 01/05/2018
28/4/18 12:57 28/4/18 12:57 1
I solved point 1) & 2) with NETWORKDAYS.INTL formula using the first column as start_date ; the second column as end_date; 11 as third formula's field to exclude Sunday as workdays; fourth formula's value pointing a column where are listed the "holidays" date .
I could not find a solution for point 3).
It will also appreciate a possible solution for point 4) .
Thank you in advance.
Formula example of above fields :
=NETWORKDAYS.INTL(N15;O15;11;Q16:Q17)
Alessandro.
I've needed to do something similar in the past. Please see the formula below. It will give you the amount of time between working days (Monday-Friday), only taking into account times 8:30am to 5:30pm. Try inserting your specific parameters.
=IFERROR((NETWORKDAYS.INTL(H8,I8,,)-1)*("17:30"-"8:30")
+IF(NETWORKDAYS.INTL(I8,I8,,),MEDIAN(MOD(I8,1),"8:30","17:30")
,"17:30")-MEDIAN(NETWORKDAYS.INTL(H8,H8,,)*MOD(H8,1),"8:30","17:30"),"")
H8 = Start Date
I8 = End Date
8:30 = Start Time
17:30 = End Time

Date comparison in excel question

I am trying to compare dates within an excel spreadsheet. The first column is the date/time the Windows user profile service starts. The second column is the date/time a particular service initiates a system shutdown. I want to create a report of all the dates that do not have a date in the second column between two consecutive dates in the first.
Any ideas on how this could be most easily accomplished? Any suggestions on where to start? Any help would be appreciated.
I asume your list is sorted on the 1st column and all date/time are really recognized as date/time by Excel (i.e. numeric). Now you want to find all rows without a shutdown date where the next row's starting date is 1 higher as this row's starting date ... meaning the integer part of next row's date/time is exactly 1 more than the integer part of this row's date/time
Create a new column "Condition" containing the formula
[C2] =AND((B2="");INT(A3)-INT(A2)=1)
and copy it all the way down; then use an Autofilter and filter for "TRUE"
example:
[A] [B] [C v] [D]
----------------------.-----------------------.----------------.----------------------------
[1] startup . shutdown . condition . comment
[2] 10.09.2011 17:45 . 10.09.2011 18:21 . FALSE .
[3] 11.09.2011 15:50 . 11.09.2011 16:26 . FALSE .
[4] 12.09.2011 13:55 . . TRUE .
[5] 13.09.2011 12:00 . 13.09.2011 12:36 . FALSE .
[6] 14.09.2011 11:59 . . FALSE . next row is same date
[7] 14.09.2011 14:08 . 14.09.2011 14:44 . FALSE .
I hope I understood your problem correctly ....

Resources