简体   繁体   English

您好,当我在 Jupyter 笔记本中执行此查询时,它会显示错误。 请帮帮我

[英]Hello When I execute this query in my Jupyter notebook it shows me error. Please help me out

Query:询问:

df['Date/Time'] = pd.to_datetime(df['Date/Time'], format="%m/%d/%Y %H:%M:%S")

Error:错误:

TypeError                                 Traceback (most recent call last)
~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _to_datetime_with_format(arg, orig_arg, name, tz, fmt, exact, errors, infer_datetime_format)
    508         try:
--> 509             values, tz = conversion.datetime_to_datetime64(arg)
    510             dta = DatetimeArray(values, dtype=tz_to_dtype(tz))

~\anaconda3\lib\site-packages\pandas\_libs\tslibs\conversion.pyx in pandas._libs.tslibs.conversion.datetime_to_datetime64()

TypeError: Unrecognized value type: <class 'str'>

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_8924/3560383786.py in <module>
----> 1 df['Date/Time'] = pd.to_datetime(df['Date/Time'], format="%m/%d/%Y %H:%M:%S")

~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache)
    885             result = arg.map(cache_array)
    886         else:
--> 887             values = convert_listlike(arg._values, format)
    888             result = arg._constructor(values, index=arg.index, name=arg.name)
    889     elif isinstance(arg, (ABCDataFrame, abc.MutableMapping)):

~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
    391 
    392     if format is not None:
--> 393         res = _to_datetime_with_format(
    394             arg, orig_arg, name, tz, format, exact, errors, infer_datetime_format
    395         )

~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _to_datetime_with_format(arg, orig_arg, name, tz, fmt, exact, errors, infer_datetime_format)
    511             return DatetimeIndex._simple_new(dta, name=name)
    512         except (ValueError, TypeError):
--> 513             raise err
    514 
    515 

~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _to_datetime_with_format(arg, orig_arg, name, tz, fmt, exact, errors, infer_datetime_format)
    498 
    499         # fallback
--> 500         res = _array_strptime_with_fallback(
    501             arg, name, tz, fmt, exact, errors, infer_datetime_format
    502         )

~\anaconda3\lib\site-packages\pandas\core\tools\datetimes.py in _array_strptime_with_fallback(arg, name, tz, fmt, exact, errors, infer_datetime_format)
    434 
    435     try:
--> 436         result, timezones = array_strptime(arg, fmt, exact=exact, errors=errors)
    437         if "%Z" in fmt or "%z" in fmt:
    438             return _return_parsed_timezone_results(result, timezones, tz, name)

~\anaconda3\lib\site-packages\pandas\_libs\tslibs\strptime.pyx in pandas._libs.tslibs.strptime.array_strptime()

ValueError: time data '09-01-2014 00:01' does not match format '%m/%d/%Y %H:%M:%S' (match)

Look at your timestamp: 09-01-2014 00:01'查看您的时间戳:09-01-2014 00:01'

what does it say to you?它对你说了什么? hours and minutes, why do you put forward slashes instead of hyphens?小时和分钟,为什么用斜杠代替连字符?

%m-%d-%Y-%H:%M

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你好,我在 kivymd 上练习,当我运行我的代码时,它显示我'未命名的 window' 有人可以帮助我吗? - hello, iam practicing on kivymd, and when i run my code it shows me 'unnamed window ' can someone help me? student() 没有 arguments 错误。 我试图检查一切都可以请任何人帮助我解决它 - student() takes no arguments error. I tried to check everything can anyone please help me in solving it 你好,请帮我处理 txt.in Python - hello,PLease help me with txt.in Python 我收到错误 [IndexError: list index out of range] 但请帮我解决这个问题 - I am getting error [ IndexError: list index out of range ] but please help me to resolve this 缩放数据的 Fit_transform 方法会引发值错误。 请帮我解决它 - Fit_transform method for scaling data throws value error. Please help me resolve it 请帮我找到代码中的语法错误 - Please help me find the syntax error in my code Jupyter notebook 给了我正确代码的错误 - Jupyter notebook is giving me error for correct codes 当我尝试将我的 Django 项目部署到 Heroku 时,它没有检测到 buildpack。 有人可以帮我吗? - When I tried to deploy to Heroku my Django project it is not detecting the buildpack. Could anyone help me please? 请纠正我。 我写的代码在笔记本里 - Correct me please . The code I wrote was in the notebook 嘿,我是编码新手,刚刚遇到一个我无法弄清楚的错误,所以请帮帮我 - Hey! I am new to coding and just got an error that I can't figure out, so please help me out
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM