'Is there a way to extract the timestamp format in Pandas?

I have a Panda Series which is a timestamp field and was imported in String format. How can I get the timestamp format of this field?

One way is to validate with each timestamp format

pd.to_datetime(x, errors='coerce', format="%m-%d-%y").notnull()

pd.to_datetime(x, errors='coerce', format="%d-%m-%y").notnull()


But this approach is not scalable as there are lot of timestamp formats and it will also be expensive operation validating every timestamps.

Is there a better way to extract the timestamp format ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source