@@ -261,7 +261,7 @@ def _convert_dataframe_to_json(dataframe,
261
261
{'measurement' : measurement ,
262
262
'tags' : dict (list (tag .items ()) + list (tags .items ())),
263
263
'fields' : rec ,
264
- 'time' : np .int64 (ts .value / precision_factor )}
264
+ 'time' : np .int64 (ts .value // precision_factor )}
265
265
for ts , tag , rec in zip (dataframe .index ,
266
266
dataframe [tag_columns ].to_dict ('record' ),
267
267
dataframe [field_columns ].to_dict ('record' ))
@@ -329,10 +329,10 @@ def _convert_dataframe_to_lines(self,
329
329
330
330
# Make array of timestamp ints
331
331
if isinstance (dataframe .index , pd .PeriodIndex ):
332
- time = ((dataframe .index .to_timestamp ().values .astype (np .int64 ) /
332
+ time = ((dataframe .index .to_timestamp ().values .astype (np .int64 ) //
333
333
precision_factor ).astype (np .int64 ).astype (str ))
334
334
else :
335
- time = ((pd .to_datetime (dataframe .index ).values .astype (np .int64 ) /
335
+ time = ((pd .to_datetime (dataframe .index ).values .astype (np .int64 ) //
336
336
precision_factor ).astype (np .int64 ).astype (str ))
337
337
338
338
# If tag columns exist, make an array of formatted tag keys and values
@@ -439,16 +439,16 @@ def _stringify_dataframe(dframe, numeric_precision, datatype='field'):
439
439
return dframe
440
440
441
441
def _datetime_to_epoch (self , datetime , time_precision = 's' ):
442
- seconds = (datetime - self .EPOCH ).total_seconds ()
442
+ nanoseconds = (datetime - self .EPOCH ).value
443
443
if time_precision == 'h' :
444
- return seconds / 3600
444
+ return np . int64 ( nanoseconds // 1e9 // 3600 )
445
445
elif time_precision == 'm' :
446
- return seconds / 60
446
+ return np . int64 ( nanoseconds // 1e9 // 60 )
447
447
elif time_precision == 's' :
448
- return seconds
448
+ return np . int64 ( nanoseconds // 1e9 )
449
449
elif time_precision == 'ms' :
450
- return seconds * 1e3
450
+ return np . int64 ( nanoseconds // 1e6 )
451
451
elif time_precision == 'u' :
452
- return seconds * 1e6
452
+ return np . int64 ( nanoseconds // 1e3 )
453
453
elif time_precision == 'n' :
454
- return seconds * 1e9
454
+ return nanoseconds
0 commit comments