Please friend is there anything wrong with this line of code

netflix_titles_df[‘year_added’] = pd.DatetimeIndex(netflix_titles_df[‘date_added’]).year

What is the error/incorrect behaviour you’ve experienced?

ParserError: Unknown string format: No date_added

whereas data_added is a column in the dataset am working on

Are you sure it’s written the exact same way? Perhaps it has capital letters, space or some dot you’ve missed.

have checked well.

this is the complete error;


TypeError Traceback (most recent call last)
~\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object, allow_mixed)
2186 try:
→ 2187 values, tz_parsed = conversion.datetime_to_datetime64(data.ravel(“K”))
2188 # If tzaware, these values represent unix timestamps, so we

~\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:

ParserError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_6760/1547925891.py in
----> 1 netflix_titles_df[‘year_added’] = pd.DatetimeIndex(netflix_titles_df[‘date_added’]).year

~\anaconda3\lib\site-packages\pandas\core\indexes\datetimes.py in new(cls, data, freq, tz, normalize, closed, ambiguous, dayfirst, yearfirst, dtype, copy, name)
331 name = maybe_extract_name(name, data, cls)
332
→ 333 dtarr = DatetimeArray._from_sequence_not_strict(
334 data,
335 dtype=dtype,

~\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py in _from_sequence_not_strict(cls, data, dtype, copy, tz, freq, dayfirst, yearfirst, ambiguous)
353 freq, freq_infer = dtl.maybe_infer_freq(freq)
354
→ 355 subarr, tz, inferred_freq = sequence_to_dt64ns(
356 data,
357 dtype=dtype,

~\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py in sequence_to_dt64ns(data, dtype, copy, tz, dayfirst, yearfirst, ambiguous, allow_object, allow_mixed, require_iso8601)
2058 # data comes back here as either i8 to denote UTC timestamps
2059 # or M8[ns] to denote wall times
→ 2060 data, inferred_tz = objects_to_datetime64ns(
2061 data,
2062 dayfirst=dayfirst,

~\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object, allow_mixed)
2191 return values.view(“i8”), tz_parsed
2192 except (ValueError, TypeError):
→ 2193 raise err
2194
2195 if tz_parsed is not None:

~\anaconda3\lib\site-packages\pandas\core\arrays\datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object, allow_mixed)
2173 order: Literal[“F”, “C”] = “F” if flags.f_contiguous else “C”
2174 try:
→ 2175 result, tz_parsed = tslib.array_to_datetime(
2176 data.ravel(“K”),
2177 errors=errors,

~\anaconda3\lib\site-packages\pandas_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime()

~\anaconda3\lib\site-packages\pandas_libs\tslib.pyx in pandas._libs.tslib.array_to_datetime()

~\anaconda3\lib\site-packages\pandas_libs\tslib.pyx in pandas._libs.tslib._array_to_datetime_object()

~\anaconda3\lib\site-packages\pandas_libs\tslib.pyx in pandas._libs.tslib._array_to_datetime_object()

~\anaconda3\lib\site-packages\pandas_libs\tslibs\parsing.pyx in pandas._libs.tslibs.parsing.parse_datetime_string()

~\anaconda3\lib\site-packages\dateutil\parser_parser.py in parse(timestr, parserinfo, **kwargs)
1366 return parser(parserinfo).parse(timestr, **kwargs)
1367 else:
→ 1368 return DEFAULTPARSER.parse(timestr, **kwargs)
1369
1370

~\anaconda3\lib\site-packages\dateutil\parser_parser.py in parse(self, timestr, default, ignoretz, tzinfos, **kwargs)
641
642 if res is None:
→ 643 raise ParserError(“Unknown string format: %s”, timestr)
644
645 if len(res) == 0:

ParserError: Unknown string format: No date_added