Problem:
While running your Python code or Jupyter notebook, you see an error message like
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /tmp/ipykernel_99995/3617538487.py in <module> 1 for date in df.index: ----> 2 print(date - pd.timedelta(5, 'years')) /usr/local/lib/python3.9/dist-packages/pandas/__init__.py in __getattr__(name) 259 return _SparseArray 260 --> 261 raise AttributeError(f"module 'pandas' has no attribute '{name}'") 262 263 AttributeError: module 'pandas' has no attribute 'timedelta'
Solution:
pandas Timedelta
is spelled with a capital T
: Timedelta
not timedelta
.