-1

I have this problem with converting string to datetime in python. but it didn't work.

enter image description here

박혜림
  • 5
  • 3
  • Please post you code and error output as text. Screenshots of code can not be accepted on Stack Overflow. – Klaus D. Jun 04 '21 at 08:33

2 Answers2

0

For 193003, The format should be

# change data type to str if not already the case
cus_data["TYMD"] = cus_data["TYMD"].astype(str)
cus_data["TYMD"] = cus_data["TYMD"].str[:4] + "-" + cus_data["TYMD"].str[4:] 

or

cus_data["TYMD"] = cus_data["TYMD"].apply(lambda x: str(x)[:4] + "-" + str(x)[4:])
AmineBTG
  • 597
  • 3
  • 13
0

%y is for short year. Ex, 2018 will be represented as 18, and %Y is for long year. In your case, your format is %y-%m, so your format should be 30-03. If you want the full year, %Y%m will work.

  • OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 9999-12-01 00:00:00 what's wrong?:( – 박혜림 Jun 04 '21 at 08:44
  • https://stackoverflow.com/questions/32888124/pandas-out-of-bounds-nanosecond-timestamp-after-offset-rollforward-plus-adding-a refer to this –  Jun 04 '21 at 08:50