Good afternoon,
I have a data set, which contains reporting dates and various parameters corresponding with this date. Each parameter provides a value related to the duration between the reports. So, the set contains multiple rows with the same date (but different time), and could contain a single row for which values are applicable to multiple dates.
Example of the set listed below:
Date Distance Price
02-01-2018 04:00 370 26.71
03-01-2018 04:00 357 27.31
04-01-2018 04:00 376 23.47
04-01-2018 04:48 8 0.72
04-01-2018 05:36 0 0.19
05-01-2018 04:00 328 23.77
05-01-2018 17:30 202 15.23
07-01-2018 17:13 7 1.54
08-01-2018 05:00 0 7.44
09-01-2018 05:00 0 3.89
10-01-2018 04:00 333 21.38
10-01-2018 11:00 110 6.40
What i would like to get:
Date Distance covered Price
02-01-2018 04:00 370 26.71
03-01-2018 04:00 357 27.31
04-01-2018 04:00 376 23.47
05-01-2018 04:00 336 24.67
06-01-2018 04:00 204 15.56
07-01-2018 04:00 4 0.77
08-01-2018 04:00 2 7.24
09-01-2018 04:00 0 3.93
10-01-2018 04:00 333 21.55
11-01-2018 04:00 110 6.40
I want to be able to choose a start date/time, and create a macro which automatically creates 24hr intervals after this date till the end of data set and interpolates the parameters.
Any help would be much appreciated. Thanks in advance.
Best regards,
Related
I'm pretty new Qlik Sense user, and I'm making pivot table which shows those patients who have been in ready status between selected time range. I have columns OWNER_ID, START_TIME, END_TIME & STATUS. START_TIME & END_TIME are in hours, for example, 6 which means 6 o'clock.
OWNER_ID
column contains those patients who have "ready status".
For now my time selection is made with filter pane and you can select "0-2 o'clock", 3-5 o'clock", "6-8 o'clock" et cetera. When I select a time range, for example 6-8 o'clock, pivot table shows those patients whose start time is 6, 7 or 8, but it should show those who have been in ready status between 6 and 8 o'clock.
I have tried aggr() chart function like
=aggr(max({1<END_TIME={">=$(=min(EHour))"}>} END_TIME),END-TIME)
within Data -> Dimensions -> END_TIME -> Field, but that doesn't work - pivot table shows OWNER_IDs whose END_TIME is greater than given time range.
How to solve this?
Seems to me if you had a data table that looked like this:
OWNER_ID
START_TIME
END_TIME
STATUS
001
05:00
10:00
Ready
002
09:00
13:00
Not Ready
003
21:00
00:00
Not Ready
004
10:00
11:00
Ready
005
09:00
12:00
Ready
...and then a table with the hours information:
START_TIME
ETIME
EHOUR
00:00
01:00
0-2 o'clock
01:00
02:00
0-2 o'clock
02:00
03:00
0-2 o'clock
03:00
04:00
3-5 o'clock
04:00
05:00
3-5 o'clock
05:00
06:00
3-5 o'clock
06:00
07:00
6-8 o'clock
07:00
08:00
6-8 o'clock
08:00
09:00
6-8 o'clock
09:00
10:00
9-11 o'clock
10:00
11:00
9-11 o'clock
11:00
12:00
9-11 o'clock
12:00
13:00
12-14 o'clock
13:00
14:00
12-14 o'clock
14:00
15:00
12-14 o'clock
15:00
16:00
15-17 o'clock
16:00
17:00
15-17 o'clock
17:00
18:00
15-17 o'clock
18:00
19:00
18-20 o'clock
19:00
20:00
18-20 o'clock
20:00
21:00
18-20 o'clock
21:00
22:00
21-23 o'clock
22:00
23:00
21-23 o'clock
23:00
00:00
21-23 o'clock
...then you'd have an association between [START_TIME] and [EHOUR], such when you select [EHOUR], it correctly filters your data by the [START_TIME]. Then, you only have to adjust your Set Expression, which I think should look more like this:
Only({<STATUS={'Ready'}>} STATUS)
Here's a screenshot GIF of how it looks for me:
Hopefully I understood that correctly!
I would like to sum the sales depending on the time diapasons of the day-night in which they occur. For example, I would like to sum all sales that happened between 22:00h and 2:00h.
Hour Sales
18:58 49
18:00 49.5
03:01 31
20:00 139
09:15 61.5
11:36 5
08:00 24
16:32 25
12:30 96.5
17:30 75.5
09:00 80
00:10 24
15:00 24
18:00 216
09:30 24
06:30 47.5
So if I try to do a sumifs where the hour is >=22:00 and <23:00, the formula works. However, if I try to sumifs the values between 22:00 and 2:00, in other words the first criteria is ">=22:00" and the second is "<2:00", the sumifs cannot work. I do understand why but I'm struggling to find an alternative way to solve this task.
As stated, we need to add 1 when it rolls to the next day, which means SUMPRODUCT:
=SUMPRODUCT($B$2:$B$17,((E2<D2)+$A$2:$A$17>=D2)*(($A$2:$A$17<D2)+$A$2:$A$17<(E2<D2)+E2))
I have a list of data with total number of orders and I would like to calculate the average number of orders per day of the week. For example, average number of order on Monday.
0 2018-01-01 00:00:00 3162
1 2018-01-02 00:00:00 1146
2 2018-01-03 00:00:00 396
3 2018-01-04 00:00:00 848
4 2018-01-05 00:00:00 1624
5 2018-01-06 00:00:00 3052
6 2018-01-07 00:00:00 3674
7 2018-01-08 00:00:00 1768
8 2018-01-09 00:00:00 1190
9 2018-01-10 00:00:00 382
10 2018-01-11 00:00:00 3170
Make sure your date column is in datetime format (looks like it already is)
Add column to convert date to day of week
Group by the day of week and take average
df['Date'] = pd.to_datetime(df['Date']) # Step 1
df['DayofWeek'] =df['Date'].dt.day_name() # Step 2
df.groupby(['DayofWeek']).mean() # Step 3
My CSV contains rows such as:
entryTime entryPrice exitTime exitPrice
06/01/2009 04:00 93.565 06/01/2009 06:00 93.825
I want to load them into a Dataframe that will have two rows per CSV row, in the following format:
datetime signal price
06/01/2009 04:00 entry 93.565
06/01/2009 06:00 exit 93.825
indexed by datetime column. What would be a fast way to do it?
Use numpy.tile with numpy.ravel:
print (df)
entryTime entryPrice exitTime exitPrice
0 01/01/2009 04:00 90.565 02/01/2009 06:00 91.825
1 03/01/2009 04:00 92.565 04/01/2009 06:00 93.825
2 05/01/2009 04:00 94.565 06/01/2009 06:00 95.825
3 07/01/2009 04:00 96.565 08/01/2009 07:00 97.825
4 09/01/2009 04:00 98.565 10/01/2009 06:00 99.825
a = np.tile(['entry','exit'], len(df))
b = df[['entryTime','exitTime']].values.ravel()
c = df[['entryPrice','exitPrice']].values.ravel()
df = pd.DataFrame({'price':c, 'signal':a},
index=pd.to_datetime(b),
columns=['signal','price'])
print (df)
signal price
2009-01-01 04:00:00 entry 90.565
2009-02-01 06:00:00 exit 91.825
2009-03-01 04:00:00 entry 92.565
2009-04-01 06:00:00 exit 93.825
2009-05-01 04:00:00 entry 94.565
2009-06-01 06:00:00 exit 95.825
2009-07-01 04:00:00 entry 96.565
2009-08-01 07:00:00 exit 97.825
2009-09-01 04:00:00 entry 98.565
2009-10-01 06:00:00 exit 99.825
From my sample xls(office2007) listed below. I am trying to calculate the hours worked from 17:00 onwards. could someone show me how would I write the formula to achieve this.
Many thanks...
Leaving Time Arrival Time DeliveryTime RTB Time per Job hoursforDaysWork
09:30:00 11:05:00 11:15:00 11:15:00 01:45:00 12:00:00
11:15:00 12:15:00 12:30:00 13:30:00 02:15:00
13:30:00 15:30:00 15:45:00 15:45:00 02:15:00
15:45:00 18:15:00 18:30:00 18:30:00 02:45:00
18:30:00 19:00:00 19:45:00 21:30:00 03:00:00
Time in Excel is based upon parts of 24 (whole day) as explained in this article.
So assuming that you care about hours after 17:00, but not after midnight, the following should help you out:
=IF(C2<17/24,0,C2-17/24)*24
C2 is the cell the calculation is for, with 17/24 giving you the time for 17:00 (5pm). The *24 at the end converts the response to be in hours instead of partial day.