6 examples of 'pandas epoch to datetime' in Python

Every line of 'pandas epoch to datetime' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
101def epoch2datetime(epoch):
102 return datetime.datetime.utcfromtimestamp(epoch)
11def _epoch_utc_to_datetime(epoch_utc):
12 """
13 Helper function for converting epoch timestamps (as stored in JWTs) into
14 python datetime objects (which are easier to use with sqlalchemy).
15 """
16 return datetime.fromtimestamp(epoch_utc)
24def _epoch_utc_to_arrow(epoch_utc):
25 """
26 生成arrow时间
27 """
28 time = arrow.get(epoch_utc)
29 return arrow.get(time.astimezone(tz.gettz("Asia/Shanghai")))
54def totimestamp(inputdate, epoch=datetime(1970,1,1)):
55 dt = datetime.strptime(inputdate, '%Y-%m-%d')
56 td = dt - epoch
57 timestamp = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 1e6 # td.total_seconds()
58 return int(timestamp)
30def converter(df: DataFrame) -> Series:
31 return df[field_name]
150def utc_timestamp_to_datetime(timestamp):
151 """
152 Converts the given timestamp to a datetime instance.
153
154 :type timestamp: float
155 :rtype: datetime
156 """
157
158 if timestamp is not None:
159 return datetime.fromtimestamp(timestamp, utc)

Related snippets