Menu
  • HOME
  • TAGS

Python/Pandas: Speedup calculation of weekday of datetime-data

python,datetime,pandas,date-conversion,weekday

In [30]: df = DataFrame(dict(date = pd.date_range('20000101',periods=100000,freq='s'), value = np.random.randn(100000))) In [31]: df['weekday'] = pd.DatetimeIndex(df['date']).weekday In [32]: %timeit pd.DatetimeIndex(df['date']).weekday 10 loops, best of 3: 34.9 ms per loop In [33]: df Out[33]: date value In [33]: df Out[33]: date value weekday 0 2000-01-01 00:00:00 -0.046604 5 1 2000-01-01 00:00:01 -1.691611...

Calculate previous week data in Teradata

teradata,weekday

Another fine use for the calendar table: select calendar_date from sys_calendar.calendar where week_of_calendar = (select week_of_calendar from sys_calendar.calendar where calendar_date = current_Date) -1 ...

SQL query to select values grouped by hour(col) and weekday(row) based on the timestamp

mysql,group-by,heatmap,weekday

Those looks like "counts" of rows. One of the issues is "sparse" data, we can address that later. To get the day of the week ('Sunday','Monday',etc.) returned, you can use the DATE_FORMAT function. To get those ordered, we need to include an integer value 0 through 6, or 1 through...

How to get first and last day in month view at DateTimePicker

c#,datetimepicker,weekday

I think it should be something like that (e.g. int year=2014; int month=12 for current month): DateTime dt = new DateTime(year, month, 1); int offset = ((int)dt.DayOfWeek - (int)CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek + 6) % 7 + 1; DateTime firstDate = dt.AddDays(-offset); DateTime lastDate = firstDate.AddDays(41); You can see that DateTimePicker puts the...

How to get the order of each day in a week?

ios,calendar,weekday

you can set programmatically start day of week by following code. To get first day of week after setting - (NSDate*)firstDayOfWeek { NSCalendar* calender = [[NSCalendar currentCalendar] copy]; [calender setFirstWeekday:2]; //Override locale to make week start on Monday NSDate* startOfTheWeek; NSTimeInterval interval; [calender rangeOfUnit:NSWeekCalendarUnit startDate:&startOfTheWeek interval:&interval forDate:self]; return startOfTheWeek; }...

Swift - Weekday by current location by currentCalendar()

ios,swift,calendar,location,weekday

For the Gregorian calendar, the weekday property of NSDateComponents is always 1 for Sunday, 2 for Monday etc. NSCalendar.currentCalendar().firstWeekday gives the (index of the) first weekday in the current locale, that could be 1 in USA and 2 in Bulgaria. Therefore var dayOfWeek = dateComps.weekday + 1 - calendar.firstWeekday if...