如何从第一个时间码获取序列中的每个后续时间码的毫秒数?
import pandas as pd
s = {1: pd.Timestamp('1970-01-28 05:28:52.235000'),
2: pd.Timestamp('1971-02-02 12:13:23.230000'),
3: pd.Timestamp('1970-09-04 17:14:53.120000')}
f = pd.DataFrame().from_dict(s, orient='index')
我完全不知道该怎么做,并且在没有很多运气的情况下尝试了谷歌搜索。
答案 0 :(得分:0)
减去两个TimeStamps
会给您一个Timedelta
,您可以使用.dt.total_seconds()
将其转换为浮点数。使用.iloc[0]
从整个Series
中减去第一个元素。
(f[0]-f[0].iloc[0]).dt.total_seconds()*1000
# because milliseconds
#1 0.000000e+00
#2 3.199227e+10
#3 1.896396e+10
#Name: 0, dtype: float64
答案 1 :(得分:0)
使用DataFrame操作进行此操作,以便Pandas完成工作。 @import Foundation;
@import Firebase;
@import UIKit;
+ (void)sendMajorOSVersionToFirebase
{
// This can only be executed once per app session.
UIDevice *myDevice = [UIDevice currentDevice];
NSString *iOSVersion = [myDevice systemVersion];
NSString *majorVersionNum;
// Two methods of getting the major version from the string
// Method 1: componentsSeparatedByString
NSArray *systemVersionArray = [iOSVersion componentsSeparatedByString:@"."];
majorVersionNum = [systemVersionArray firstObject];
// Method 2: range and substringToIndex
NSRange range = [iOSVersion rangeOfString:@"." options: nil];
majorVersion = [iOSVersion substringToIndex: range.location];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[FIRAnalytics setUserPropertyString:majorVersion forName:@"iOSMajorVersion"];
});
}
显示第一个值和每个后续值之间的毫秒差。 import Firebase
import Foundation
import UIKit
class func sendMajorOSVersionToFirebase() {
// This can only be executed once per app session.
let myDevice = UIDevice.current
let iOSVersion = myDevice.systemVersion
var majorVersionNum: String
// Two methods of getting the major version from the string
// Method 1: componentsSeparatedByString
let systemVersionArray = iOSVersion.components(separatedBy: ".")
majorVersionNum = systemVersionArray.first ?? ""
// Method 2: range and substringToIndex
let range: NSRange = (iOSVersion as NSString).range(of: ".", options: nil)
majorVersion = (iOSVersion as? NSString)?.substring(to: range.location)
// TODO: ensure that the code below is executed only once.
{
FIRAnalytics.setUserPropertyString(majorVersion, forName: @"iOSMajorVersion")
}
}
显示每行之间的毫秒数。
total_delta_time_ms