Home>
Currently, I am creating a function that preprocesses data by python, but I am in trouble because an error occurs.
【Thing I want to do】
I want to extract the first 8 digits from the ID column and convert it to a date type.
・ ID column
→ 16-digit number (objevt type)
[Created function]
def preprocessing (result):
df = result.copy ()
df ["date"] = df ["ID"]. map (lambda x: str (x) [0: 8])
df ["date"] = pd.to_datetime (df ["date"], format ='% Y year% m month% d day')
return df
[Error occurring]
ValueError: time data '20191228' does not match format'% Y year% m month% d day' (match)
I intended to investigate various things, but I couldn't find the cause at all.
-
Answer # 1
Related articles
- python 3x - about value error in keras predict
- python - i don't know the solution and cause of the attribute error that occurred when using pillow
- python error (about arrays)
- python - about the error log output method
- about python type error
- python 3x - about the contents of python error code
- python - about anaconda exec format error
- python - about noreversematch error
- google apps script - i get an error about pushing bubble messages with line messaging api in gas
- syntaxerror: invalid syntax error python
- python 3x - about return code of python3 subprocess
- python: about loops in leap motion programs
- python - i'm not sure about add_axes in matplotlib
- the cause of the error related to the c language memory area is unknown
- python - about the fibonacci sequence using recursion
- python 3x - an error occurs after registering a dictionary with a read-aloud bot on discordpy
- about the description of try except in python
- python - attributeerror:'series' object has no attribute'flags' error
- python - about xss measures when the user does {{safe}} when displaying markdown with a template in django
Trends
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
pd.to_datetime (df ["date"], format ='% Y year% m month% d day')
IsOctober 2, 1992
It is a process to convert a format like to Timestamp, but it does not match that format20191228
Is the valuedf ["date"]
It means that it was there.YYYYMMDD
Can be converted to Timestamp without specifying the format, so please modify it as follows.