I got some problem with converting jalali date string to python date time object with pandas.to_datetime for example when i run this simple code :
print(pd.to_datetime('1399/05/02',format='%Y/%m/%d'))
I got this error :
TypeError Traceback (most recent call last)
~\anaconda3\envs\tf2\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1857 try:
-> 1858 values, tz_parsed = conversion.datetime_to_datetime64(data)
1859 # If tzaware, these values represent unix timestamps, so we
pandas\_libs\tslibs\conversion.pyx in pandas._libs.tslibs.conversion.datetime_to_datetime64()
TypeError: Unrecognized value type:
During handling of the above exception, another exception occurred:
OutOfBoundsDatetime Traceback (most recent call last)
in
1 #dbs.Irdate = pd.to_datetime(dbs.Irdate,format='%Y/%m/%d',yearfirst = True)
----> 2 print(pd.to_datetime('1399/05/02',format='%Y/%m/%d'))
~\anaconda3\envs\tf2\lib\site-packages\pandas\core\tools\datetimes.py in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache)
754 result = convert_listlike(arg, format)
755 else:
--> 756 result = convert_listlike(np.array([arg]), format)[0]
757
758 return result
~\anaconda3\envs\tf2\lib\site-packages\pandas\core\tools\datetimes.py in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
445 errors=errors,
446 require_iso8601=require_iso8601,
--> 447 allow_object=True,
448 )
449
~\anaconda3\envs\tf2\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1861 return values.view("i8"), tz_parsed
1862 except (ValueError, TypeError):
-> 1863 raise e
1864
1865 if tz_parsed is not None:
~\anaconda3\envs\tf2\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
1852 dayfirst=dayfirst,
1853 yearfirst=yearfirst,
-> 1854 require_iso8601=require_iso8601,
1855 )
1856 except ValueError as e:
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas\_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas\_libs\tslibs\np_datetime.pyx in pandas._libs.tslibs.np_datetime.check_dts_bounds()
**OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 1399-05-02 00:00:00**
so i use this Parameter errors='ignore' for fixing errors but result is unacceptable for example :
print(pd.to_datetime('1399/05/02',format='%Y/%m/%d', errors='ignore'))
result is : 1399/05/02 so you can see nothing change i want some thing like this 1399-05-02 the python date time object please help me