Skip to content

Tutorial: conversions

Paul Alexander Bilokon edited this page Dec 15, 2024 · 1 revision

Tutorial for thalesians.aduitor.conversions

This tutorial demonstrates the usage of various conversion functions available in the thalesians.adiutor.conversions module.

1. Converting numpy.datetime64 to datetime.datetime

numpy_datetime64 = np.datetime64('2019-09-10T14:19:31.357')
python_datetime = conv.numpy_datetime64_to_python_datetime(numpy_datetime64)
print(python_datetime)  # Output: 2019-09-10 14:19:31.357000

2. Converting pandas.Timestamp to datetime.datetime

pandas_timestamp = pd.Timestamp('2019-09-10 14:19:31.357')
python_datetime = conv.pandas_timestamp_to_python_datetime(pandas_timestamp)
print(python_datetime)  # Output: 2019-09-10 14:19:31.357000

3. Converting numpy.timedelta64 to datetime.timedelta

numpy_timedelta64 = np.timedelta64(5, 's')
python_timedelta = conv.numpy_timedelta64_to_python_timedelta(numpy_timedelta64)
print(python_timedelta)  # Output: 0:00:05

... (continue similarly for all other methods from the test cases, providing examples and expected outputs)


Refer to the test cases for a comprehensive list of supported formats and use cases.

Clone this wiki locally