forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathperiod_helper.c
689 lines (565 loc) · 20.8 KB
/
period_helper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
/*
Copyright (c) 2016, PyData Development Team
All rights reserved.
Distributed under the terms of the BSD Simplified License.
The full license is in the LICENSE file, distributed with this software.
Borrowed and derived code from scikits.timeseries that we will expose via
Cython to pandas. This primarily concerns interval representation and
frequency conversion routines.
See end of file for stuff pandas uses (search for 'pandas').
*/
#include "period_helper.h"
#include "../datetime/np_datetime.h"
/* ------------------------------------------------------------------
* Code derived from scikits.timeseries
* ------------------------------------------------------------------*/
static int mod_compat(int x, int m) {
int result = x % m;
if (result < 0) return result + m;
return result;
}
static int floordiv(int x, int divisor) {
if (x < 0) {
if (mod_compat(x, divisor)) {
return x / divisor - 1;
} else {
return x / divisor;
}
} else {
return x / divisor;
}
}
static int monthToQuarter(int month) { return ((month - 1) / 3) + 1; }
/* Find the absdate (days elapsed since datetime(1, 1, 1)
* for the given year/month/day.
* Assumes GREGORIAN_CALENDAR */
npy_int64 absdate_from_ymd(int year, int month, int day) {
/* Calculate the absolute date */
pandas_datetimestruct dts;
npy_int64 unix_date;
memset(&dts, 0, sizeof(pandas_datetimestruct));
dts.year = year;
dts.month = month;
dts.day = day;
unix_date = pandas_datetimestruct_to_datetime(PANDAS_FR_D, &dts);
return ORD_OFFSET + unix_date;
}
/* Sets the date part of the date_info struct
Assumes GREGORIAN_CALENDAR */
static int dInfoCalc_SetFromAbsDate(register struct date_info *dinfo,
npy_int64 absdate) {
pandas_datetimestruct dts;
pandas_datetime_to_datetimestruct(absdate - ORD_OFFSET, PANDAS_FR_D, &dts);
dinfo->year = dts.year;
dinfo->month = dts.month;
dinfo->day = dts.day;
return 0;
}
///////////////////////////////////////////////
// frequency specific conversion routines
// each function must take an integer fromDate and
// a char relation ('S' or 'E' for 'START' or 'END')
///////////////////////////////////////////////////////////////////////
// helpers for frequency conversion routines //
static npy_int64 daytime_conversion_factor_matrix[7][7] = {
{1, 24, 1440, 86400, 86400000, 86400000000, 86400000000000},
{0, 1, 60, 3600, 3600000, 3600000000, 3600000000000},
{0, 0, 1, 60, 60000, 60000000, 60000000000},
{0, 0, 0, 1, 1000, 1000000, 1000000000},
{0, 0, 0, 0, 1, 1000, 1000000},
{0, 0, 0, 0, 0, 1, 1000},
{0, 0, 0, 0, 0, 0, 1}};
PANDAS_INLINE int max_value(int a, int b) { return a > b ? a : b; }
PANDAS_INLINE int min_value(int a, int b) { return a < b ? a : b; }
PANDAS_INLINE int get_freq_group(int freq) { return (freq / 1000) * 1000; }
PANDAS_INLINE int get_freq_group_index(int freq) { return freq / 1000; }
npy_int64 get_daytime_conversion_factor(int from_index, int to_index) {
int row = min_value(from_index, to_index);
int col = max_value(from_index, to_index);
// row or col < 6 means frequency strictly lower than Daily, which
// do not use daytime_conversion_factors
if (row < 6) {
return 0;
} else if (col < 6) {
return 0;
}
return daytime_conversion_factor_matrix[row - 6][col - 6];
}
PANDAS_INLINE npy_int64 upsample_daytime(npy_int64 ordinal,
asfreq_info *af_info) {
if (af_info->is_end) {
return (ordinal + 1) * af_info->intraday_conversion_factor - 1;
} else {
return ordinal * af_info->intraday_conversion_factor;
}
}
PANDAS_INLINE npy_int64 downsample_daytime(npy_int64 ordinal,
asfreq_info *af_info) {
return ordinal / (af_info->intraday_conversion_factor);
}
PANDAS_INLINE npy_int64 transform_via_day(npy_int64 ordinal,
asfreq_info *af_info,
freq_conv_func first_func,
freq_conv_func second_func) {
npy_int64 result;
result = (*first_func)(ordinal, af_info);
result = (*second_func)(result, af_info);
return result;
}
static npy_int64 DtoB_weekday(npy_int64 absdate) {
return floordiv(absdate, 7) * 5 + mod_compat(absdate, 7) - BDAY_OFFSET;
}
static npy_int64 DtoB(struct date_info *dinfo,
int roll_back, npy_int64 absdate) {
int day_of_week = dayofweek(dinfo->year, dinfo->month, dinfo->day);
if (roll_back == 1) {
if (day_of_week > 4) {
// change to friday before weekend
absdate -= (day_of_week - 4);
}
} else {
if (day_of_week > 4) {
// change to Monday after weekend
absdate += (7 - day_of_week);
}
}
return DtoB_weekday(absdate);
}
//************ FROM DAILY ***************
static npy_int64 asfreq_DTtoA(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
ordinal = downsample_daytime(ordinal, af_info);
dInfoCalc_SetFromAbsDate(&dinfo, ordinal + ORD_OFFSET);
if (dinfo.month > af_info->to_a_year_end) {
return (npy_int64)(dinfo.year + 1 - BASE_YEAR);
} else {
return (npy_int64)(dinfo.year - BASE_YEAR);
}
}
static npy_int64 DtoQ_yq(npy_int64 ordinal, asfreq_info *af_info, int *year,
int *quarter) {
struct date_info dinfo;
dInfoCalc_SetFromAbsDate(&dinfo, ordinal + ORD_OFFSET);
if (af_info->to_q_year_end != 12) {
dinfo.month -= af_info->to_q_year_end;
if (dinfo.month <= 0) {
dinfo.month += 12;
} else {
dinfo.year += 1;
}
}
*year = dinfo.year;
*quarter = monthToQuarter(dinfo.month);
return 0;
}
static npy_int64 asfreq_DTtoQ(npy_int64 ordinal, asfreq_info *af_info) {
int year, quarter;
ordinal = downsample_daytime(ordinal, af_info);
DtoQ_yq(ordinal, af_info, &year, &quarter);
return (npy_int64)((year - BASE_YEAR) * 4 + quarter - 1);
}
static npy_int64 asfreq_DTtoM(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
ordinal = downsample_daytime(ordinal, af_info);
dInfoCalc_SetFromAbsDate(&dinfo, ordinal + ORD_OFFSET);
return (npy_int64)((dinfo.year - BASE_YEAR) * 12 + dinfo.month - 1);
}
static npy_int64 asfreq_DTtoW(npy_int64 ordinal, asfreq_info *af_info) {
ordinal = downsample_daytime(ordinal, af_info);
return (ordinal + ORD_OFFSET - (1 + af_info->to_week_end)) / 7 + 1 -
WEEK_OFFSET;
}
static npy_int64 asfreq_DTtoB(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
npy_int64 absdate;
int roll_back;
ordinal = downsample_daytime(ordinal, af_info);
absdate = ordinal + ORD_OFFSET;
dInfoCalc_SetFromAbsDate(&dinfo, absdate);
// This usage defines roll_back the opposite way from the others
roll_back = 1 - af_info->is_end;
return DtoB(&dinfo, roll_back, absdate);
}
// all intra day calculations are now done within one function
static npy_int64 asfreq_DownsampleWithinDay(npy_int64 ordinal,
asfreq_info *af_info) {
return downsample_daytime(ordinal, af_info);
}
static npy_int64 asfreq_UpsampleWithinDay(npy_int64 ordinal,
asfreq_info *af_info) {
return upsample_daytime(ordinal, af_info);
}
//************ FROM BUSINESS ***************
static npy_int64 asfreq_BtoDT(npy_int64 ordinal, asfreq_info *af_info) {
ordinal += BDAY_OFFSET;
ordinal =
(floordiv(ordinal - 1, 5) * 7 + mod_compat(ordinal - 1, 5) + 1 -
ORD_OFFSET);
return upsample_daytime(ordinal, af_info);
}
static npy_int64 asfreq_BtoA(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_BtoDT, asfreq_DTtoA);
}
static npy_int64 asfreq_BtoQ(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_BtoDT, asfreq_DTtoQ);
}
static npy_int64 asfreq_BtoM(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_BtoDT, asfreq_DTtoM);
}
static npy_int64 asfreq_BtoW(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_BtoDT, asfreq_DTtoW);
}
//************ FROM WEEKLY ***************
static npy_int64 asfreq_WtoDT(npy_int64 ordinal, asfreq_info *af_info) {
ordinal = (ordinal + WEEK_OFFSET) * 7 +
af_info->from_week_end - ORD_OFFSET +
(7 - 1) * (af_info->is_end - 1);
return upsample_daytime(ordinal, af_info);
}
static npy_int64 asfreq_WtoA(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_WtoDT, asfreq_DTtoA);
}
static npy_int64 asfreq_WtoQ(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_WtoDT, asfreq_DTtoQ);
}
static npy_int64 asfreq_WtoM(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_WtoDT, asfreq_DTtoM);
}
static npy_int64 asfreq_WtoW(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_WtoDT, asfreq_DTtoW);
}
static npy_int64 asfreq_WtoB(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
npy_int64 absdate = asfreq_WtoDT(ordinal, af_info) + ORD_OFFSET;
int roll_back = af_info->is_end;
dInfoCalc_SetFromAbsDate(&dinfo, absdate);
return DtoB(&dinfo, roll_back, absdate);
}
//************ FROM MONTHLY ***************
static void MtoD_ym(npy_int64 ordinal, int *y, int *m) {
*y = floordiv(ordinal, 12) + BASE_YEAR;
*m = mod_compat(ordinal, 12) + 1;
}
static npy_int64 asfreq_MtoDT(npy_int64 ordinal, asfreq_info *af_info) {
npy_int64 absdate;
int y, m;
ordinal += af_info->is_end;
MtoD_ym(ordinal, &y, &m);
absdate = absdate_from_ymd(y, m, 1);
ordinal = absdate - ORD_OFFSET;
ordinal -= af_info->is_end;
return upsample_daytime(ordinal, af_info);
}
static npy_int64 asfreq_MtoA(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_MtoDT, asfreq_DTtoA);
}
static npy_int64 asfreq_MtoQ(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_MtoDT, asfreq_DTtoQ);
}
static npy_int64 asfreq_MtoW(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_MtoDT, asfreq_DTtoW);
}
static npy_int64 asfreq_MtoB(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
npy_int64 absdate = asfreq_MtoDT(ordinal, af_info) + ORD_OFFSET;
int roll_back = af_info->is_end;
dInfoCalc_SetFromAbsDate(&dinfo, absdate);
return DtoB(&dinfo, roll_back, absdate);
}
//************ FROM QUARTERLY ***************
static void QtoD_ym(npy_int64 ordinal, int *y, int *m, asfreq_info *af_info) {
*y = floordiv(ordinal, 4) + BASE_YEAR;
*m = mod_compat(ordinal, 4) * 3 + 1;
if (af_info->from_q_year_end != 12) {
*m += af_info->from_q_year_end;
if (*m > 12) {
*m -= 12;
} else {
*y -= 1;
}
}
}
static npy_int64 asfreq_QtoDT(npy_int64 ordinal, asfreq_info *af_info) {
npy_int64 absdate;
int y, m;
ordinal += af_info->is_end;
QtoD_ym(ordinal, &y, &m, af_info);
absdate = absdate_from_ymd(y, m, 1);
absdate -= af_info->is_end;
return upsample_daytime(absdate - ORD_OFFSET, af_info);
}
static npy_int64 asfreq_QtoQ(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_QtoDT, asfreq_DTtoQ);
}
static npy_int64 asfreq_QtoA(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_QtoDT, asfreq_DTtoA);
}
static npy_int64 asfreq_QtoM(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_QtoDT, asfreq_DTtoM);
}
static npy_int64 asfreq_QtoW(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_QtoDT, asfreq_DTtoW);
}
static npy_int64 asfreq_QtoB(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
npy_int64 absdate = asfreq_QtoDT(ordinal, af_info) + ORD_OFFSET;
int roll_back = af_info->is_end;
dInfoCalc_SetFromAbsDate(&dinfo, absdate);
return DtoB(&dinfo, roll_back, absdate);
}
//************ FROM ANNUAL ***************
static npy_int64 asfreq_AtoDT(npy_int64 ordinal, asfreq_info *af_info) {
npy_int64 absdate;
// start from 1970
npy_int64 year = ordinal + BASE_YEAR;
int month = (af_info->from_a_year_end % 12) + 1;
if (af_info->from_a_year_end != 12) {
year -= 1;
}
year += af_info->is_end;
absdate = absdate_from_ymd(year, month, 1);
absdate -= af_info->is_end;
return upsample_daytime(absdate - ORD_OFFSET, af_info);
}
static npy_int64 asfreq_AtoA(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_AtoDT, asfreq_DTtoA);
}
static npy_int64 asfreq_AtoQ(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_AtoDT, asfreq_DTtoQ);
}
static npy_int64 asfreq_AtoM(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_AtoDT, asfreq_DTtoM);
}
static npy_int64 asfreq_AtoW(npy_int64 ordinal, asfreq_info *af_info) {
return transform_via_day(ordinal, af_info, asfreq_AtoDT, asfreq_DTtoW);
}
static npy_int64 asfreq_AtoB(npy_int64 ordinal, asfreq_info *af_info) {
struct date_info dinfo;
npy_int64 absdate = asfreq_AtoDT(ordinal, af_info) + ORD_OFFSET;
int roll_back = af_info->is_end;
dInfoCalc_SetFromAbsDate(&dinfo, absdate);
return DtoB(&dinfo, roll_back, absdate);
}
static npy_int64 nofunc(npy_int64 ordinal, asfreq_info *af_info) {
return INT_ERR_CODE;
}
static npy_int64 no_op(npy_int64 ordinal, asfreq_info *af_info) {
return ordinal;
}
// end of frequency specific conversion routines
static int calc_a_year_end(int freq, int group) {
int result = (freq - group) % 12;
if (result == 0) {
return 12;
} else {
return result;
}
}
static int calc_week_end(int freq, int group) { return freq - group; }
void get_asfreq_info(int fromFreq, int toFreq, char relation,
asfreq_info *af_info) {
int fromGroup = get_freq_group(fromFreq);
int toGroup = get_freq_group(toFreq);
if (relation == 'E') {
af_info->is_end = 1;
} else {
af_info->is_end = 0;
}
af_info->intraday_conversion_factor = get_daytime_conversion_factor(
get_freq_group_index(max_value(fromGroup, FR_DAY)),
get_freq_group_index(max_value(toGroup, FR_DAY)));
switch (fromGroup) {
case FR_WK:
af_info->from_week_end = calc_week_end(fromFreq, fromGroup);
break;
case FR_ANN:
af_info->from_a_year_end = calc_a_year_end(fromFreq, fromGroup);
break;
case FR_QTR:
af_info->from_q_year_end = calc_a_year_end(fromFreq, fromGroup);
break;
}
switch (toGroup) {
case FR_WK:
af_info->to_week_end = calc_week_end(toFreq, toGroup);
break;
case FR_ANN:
af_info->to_a_year_end = calc_a_year_end(toFreq, toGroup);
break;
case FR_QTR:
af_info->to_q_year_end = calc_a_year_end(toFreq, toGroup);
break;
}
}
freq_conv_func get_asfreq_func(int fromFreq, int toFreq) {
int fromGroup = get_freq_group(fromFreq);
int toGroup = get_freq_group(toFreq);
if (fromGroup == FR_UND) {
fromGroup = FR_DAY;
}
switch (fromGroup) {
case FR_ANN:
switch (toGroup) {
case FR_ANN:
return &asfreq_AtoA;
case FR_QTR:
return &asfreq_AtoQ;
case FR_MTH:
return &asfreq_AtoM;
case FR_WK:
return &asfreq_AtoW;
case FR_BUS:
return &asfreq_AtoB;
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
return &asfreq_AtoDT;
default:
return &nofunc;
}
case FR_QTR:
switch (toGroup) {
case FR_ANN:
return &asfreq_QtoA;
case FR_QTR:
return &asfreq_QtoQ;
case FR_MTH:
return &asfreq_QtoM;
case FR_WK:
return &asfreq_QtoW;
case FR_BUS:
return &asfreq_QtoB;
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
return &asfreq_QtoDT;
default:
return &nofunc;
}
case FR_MTH:
switch (toGroup) {
case FR_ANN:
return &asfreq_MtoA;
case FR_QTR:
return &asfreq_MtoQ;
case FR_MTH:
return &no_op;
case FR_WK:
return &asfreq_MtoW;
case FR_BUS:
return &asfreq_MtoB;
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
return &asfreq_MtoDT;
default:
return &nofunc;
}
case FR_WK:
switch (toGroup) {
case FR_ANN:
return &asfreq_WtoA;
case FR_QTR:
return &asfreq_WtoQ;
case FR_MTH:
return &asfreq_WtoM;
case FR_WK:
return &asfreq_WtoW;
case FR_BUS:
return &asfreq_WtoB;
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
return &asfreq_WtoDT;
default:
return &nofunc;
}
case FR_BUS:
switch (toGroup) {
case FR_ANN:
return &asfreq_BtoA;
case FR_QTR:
return &asfreq_BtoQ;
case FR_MTH:
return &asfreq_BtoM;
case FR_WK:
return &asfreq_BtoW;
case FR_BUS:
return &no_op;
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
return &asfreq_BtoDT;
default:
return &nofunc;
}
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
switch (toGroup) {
case FR_ANN:
return &asfreq_DTtoA;
case FR_QTR:
return &asfreq_DTtoQ;
case FR_MTH:
return &asfreq_DTtoM;
case FR_WK:
return &asfreq_DTtoW;
case FR_BUS:
return &asfreq_DTtoB;
case FR_DAY:
case FR_HR:
case FR_MIN:
case FR_SEC:
case FR_MS:
case FR_US:
case FR_NS:
if (fromGroup > toGroup) {
return &asfreq_DownsampleWithinDay;
} else {
return &asfreq_UpsampleWithinDay;
}
default:
return &nofunc;
}
default:
return &nofunc;
}
}
/* ------------------------------------------------------------------
* New pandas API-helper code, to expose to cython
* ------------------------------------------------------------------*/
npy_int64 asfreq(npy_int64 period_ordinal, int freq1, int freq2,
char relation) {
npy_int64 val;
freq_conv_func func;
asfreq_info finfo;
func = get_asfreq_func(freq1, freq2);
get_asfreq_info(freq1, freq2, relation, &finfo);
val = (*func)(period_ordinal, &finfo);
return val;
}