For a given timedata - 2018-06-01 06:36:40.047883+00:00
, I want to remove microsecond and strip the value after '+'. Most of my dataset contains values like 2018-06-04 11:30:00+00:00
without the microsecond part.
How to have a common date time format for all values?
I'm answering your question with an assumption that the type of the data is a string.
If you are facing problem in handling in different formats like "2018-06-01 06:36:40.047883+00:00"
and "2018-06-04 11:30:00+00:00"
you can use split()
. Learn more about split()
at here
str_data_time.split("+")[0].split(".")[0]
for str_data_time in ["2018-06-01 06:36:40.047883+00:00", "2018-06-04 11:30:00+00:00"]:
output = str_data_time.split("+")[0].split(".")[0]
print(output)
The output of the above script is,
2018-06-01 06:36:40
2018-06-04 11:30:00
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加