[Python] Conversion memo between time data and numerical data

Conversion of numerical data to time data

Personal notes

Note that I make many mistakes in converting numerical values and time series data in the dataframe. Conversion that converts the following data (seconds) to time

> df['Time']
0        30620.5
1        39226.0
2        81318.5
3         3438.0
4        11108.5
          ...   
40916     3544.0
40917    37506.0
40918    23386.0
40919    37884.5
40920    24607.5
Name: Time, Length: 40921, dtype: float64
> df['Time']=pd.to_timedelta(df['Time'], unit='S') + pd.to_datetime('1900-01-01')
> df[Time]
0       1900-01-01 08:30:20.500
1       1900-01-01 10:53:46.000
2       1900-01-01 22:35:18.500
3       1900-01-01 00:57:18.000
4       1900-01-01 03:05:08.500
                  ...          
40916   1900-01-01 00:59:04.000
40917   1900-01-01 10:25:06.000
40918   1900-01-01 06:29:46.000
40919   1900-01-01 10:31:24.500
40920   1900-01-01 06:50:07.500
Name: Time, Length: 40921, dtype: datetime64[ns]

Ref : pandas.to_timedelta

unit str, optional Denotes the unit of the arg for numeric arg. Defaults to "ns".

Possible values

Changed in version 1.1.0: Must not be specified when arg context strings and errors="raise".

Recommended Posts

[Python] Conversion memo between time data and numerical data
Difference between java and python (memo)
Python data structure and operation (Python learning memo ③)
Exchange encrypted data between Python and C #
Relationship between Firestore and Go data type conversion
[Python] Summary of conversion between character strings and numerical values (ascii code)
Mutual conversion between JSON and YAML / TOML in Python
Codility lesson time complexity and my answer memo (Python)
Python execution time measurement memo
Conversion between unixtime and datetime
Python data type summary memo
[Python] Plot time series data
Image data type conversion [Python]
Graph time series data in Python using pandas and matplotlib
Difference between Ruby and Python split
Difference between list () and [] in Python
Python: Time Series Analysis: Preprocessing Time Series Data
Python QT app Standalone App conversion memo
Memo "Chapter 5 – Dictionaries and Structuring Data"
Cooperation between python module and API
Differences between Python, stftime and strptime
Difference between python2 series and python3 series dict.keys ()
Hashing data in R and Python
About time series data and overfitting
Python memo ① Folder and file operations
[Python] Difference between function and method
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
Comparison of time series data predictions between SARIMA and Prophet models
Basic map information using Python Geotiff conversion of numerical elevation data
Communicate between Elixir and Python with gRPC
Data pipeline construction with Python and Luigi
Differences in authenticity between Python and JavaScript
Statistical basics and Python, graphing, etc. (memo)
Differences between Ruby and Python in scope
difference between statements (statements) and expressions (expressions) in Python
python memo
Python memo
Difference between @classmethod and @staticmethod in Python
A memo with Python2.7 and Python3 on CentOS
Easily exchange data between Python, R and Julia using the Feather format
Python data structure and internal implementation ~ List ~
[Python] Case where the execution time differs between the built-in list and deque
Difference between append and + = in Python list
Difference between nonlocal and global in Python
[Python] Difference between class method and static method
python memo
Easily graph data in shell and Python
Python memo
[Python3] Switch between Shift_JIS, UTF-8 and ASCII
Conversion of time data in 25 o'clock notation
[Python Iroha] Difference between List and Tuple
Conversion between singular and plural of words
[python] Difference between rand and randn output
Python: Preprocessing in machine learning: Data conversion
Compress python data and write to sqlite
Differences in multithreading between Python and Jython
Differences between Ruby and Python (basic syntax)
Reading OpenFOAM time series data and sets data
Python memo