Epoch to human readable date using Python
In this post, I am going to convert epoch to human readable date using python. In time-series data, most of the time, epochs are given instead of human-readable time. In those scenarios, we may need to convert epochs to human-readable time.
Dataset
I am going to take a very simple dataset that I have created. The dataset includes two columns, first column “timestamp” and the second column “values”.The objective is to convert timestamp into a human-readable date.
#importing necessary libraries
import numpy as np
import pandas as pd
import time# Reading the dataset
data= pd.read_csv('/home/sakil/Desktop/test_data.csv')
data.head()
#parsing timestamp to human readable date and storing the date in humanreadabledate column
humanreadabledate =[]
for i in data.timestamp:
humanreadabledate.append(time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(i)))
data['humanreadabledate ']=humanreadabledatedata.head()
%Y-%m-%d %H:%M:%S:
You can specify your date format.I have taken one another date format example which is shown below
humanreadabledate =[]
for i in data.timestamp:
humanreadabledate.append(time.strftime("%Y-%m-%d ", time.gmtime(i)))
data['humanreadabledate ']=humanreadabledatedata.head()
This is a small post that may be useful for data scientists while converting epoch to human readable date format.