3

If I have it infer the format when converting a column in pandas to datetimes, is there a way I can go backwards and retrieve the formatting?

E.g. if I have columns full of date times like "02-09-1990 10:32PM" and I convert that with with pandas.to_datatime, is there a way to retrieve the format it used out of there?

I dug into the functions that to_datetime uses to infer, namely:

from pandas._libs.tslibs.parsing import _guess_datetime_format
from pandas.core.tools.datetimes import _guess_datetime_format_for_array

but I can't get them to actually work and I can't step into their code to figure out why in PyCharm.

Anyone have any ideas on this? Thank you.

J C
  • 79
  • 5
  • This is an interesting question. Can you provide some context on why you'd like to recover the string format? – Oliver Evans Jul 11 '18 at 01:44
  • https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/tslibs/parsing.pyxGood find @kitman0804. J C I'm guessing that you can't get the source for these functions because they're cython, but you can find it [on GitHub](https://github.com/pandas-dev/pandas/blob/5d0daa0522730a6f999ceaf328f63f03dd62d0b4/pandas/_libs/tslibs/parsing.pyx#L561) – Oliver Evans Jul 11 '18 at 01:53
  • Question is unclear , that is why you have two deleted answer before. Make it clear next time . thank you – BENY Jul 11 '18 at 02:29

0 Answers0