The Pandas Timestamp function fromtimestamp() used to transform timestamp[, tz] to tz’s local time from POSIX timestamp. It returns a Timestamp object that includes Timestamp.
1 classmethod Timestamp.fromtimestamp(ts)
1 import pandas as pd
2
3 res = pd.Timestamp.fromtimestamp(1684199972)
4 print('A timestamp from POSIX timestamp :')
5 print(res)
In the above example, a fromtimestamp() function is called by passing a timestamp value that transform timestamp[, tz] to tz’s local time from POSIX timestamp. The result is assign to the variable that will be printed on console.
1 A timestamp from POSIX timestamp :
2 2023-05-16 06:49:32
Note : The result may vary depending on system local time.
Example 2
1 import pandas as pd
2
3 res = pd.Timestamp.fromtimestamp(15426854)
4
5 print('A timestamp from POSIX timestamp :')
6 print(res)
In the above example, a fromtimestamp() function is called by passing a timestamp value that transform timestamp[, tz] to tz’s local time from POSIX timestamp. The result is assign to the variable that will be print.
1 A timestamp from POSIX timestamp :
2 1970-06-28 13:14:14
Related options for your search