Quick answer
This means you called a datetime accessor like .month on an integer index. Datetime accessors only exist on datetime-typed objects, so convert first with df.index = pd.to_datetime(df.index), or use pd.to_datetime(df['date']).dt.month for a column. Note that Int64Index itself was removed in pandas 2.0 — use pd.api.types.is_integer_dtype() instead of isinstance checks.
AttributeError: 'Int64Index' object has no attribute 'month' looks like a pandas bug but is really a type mismatch: you asked for a calendar property from something that isn't a date. The .month accessor reads a datetime64 value under the hood, and an integer index has no such value to read.
What the error means
.month, .year, .day, .hour, .dayofweek, and friends are datetime accessors. They exist on exactly two things:
- a
DatetimeIndex(used asdf.index.month), and - a datetime
Series, via the.dtaccessor (used asdf['date'].dt.month).
If df.index is an integer index — pandas calls it Int64Index before 2.0, or just Index with dtype='int64' after — it has no .month, so Python raises AttributeError. The index might display like dates (20230101) and still be plain integers.
Why it happens
- The dates were never parsed.
pd.read_csv(...)withoutparse_datesleaves a date column as strings (object) or integers, and setting it as the index gives you a non-datetime index. - A transformation reset the type. A
groupby,reset_index, or arithmetic step can produce a fresh integer index where you expected the datetime one. .dtis missing (or wrongly present). On a Series you need.dt.month; on an index you need plain.month. Using the wrong one triggers this error or its cousin, "Can only use .dt accessor with datetimelike values."- pandas 2.0 removed the class.
Int64Index/Float64Index/UInt64Indexare gone. Any code — yours or a dependency's — doingisinstance(idx, pd.Int64Index)now fails withAttributeError: module 'pandas' has no attribute 'Int64Index'.
Diagnose it
Print the type before you touch the accessor:
print(df.index.dtype) # int64 → not datetimes
print(type(df.index)) # <class 'pandas.core.indexes.base.Index'> or Int64Index
print(df.index[:3]) # looks like dates but may be intsIf dtype is int64 or object, that's your answer.
The fixes
Convert the index to real datetimes, then the accessor works:
df.index = pd.to_datetime(df.index) # now a DatetimeIndex
df["month"] = df.index.month # worksWorking from a column instead? Convert the column and use .dt:
df["month"] = pd.to_datetime(df["date"]).dt.monthHitting the pandas 2.0 Int64Index removal? Replace isinstance checks with dtype predicates:
# Before (breaks on pandas 2.0)
if isinstance(df.index, pd.Int64Index): ...
# After
if pd.api.types.is_integer_dtype(df.index): ...If the offending isinstance lives inside a third-party package, upgrade it — older statsmodels, scikit-learn, and xarray releases referenced the removed classes and have since been patched.
Prevent it
- Parse dates at load time:
pd.read_csv(path, parse_dates=["date"], index_col="date")hands you aDatetimeIndeximmediately. - Convert once, early, right after loading, so every downstream step already has the right type.
- Assert the type in pipelines that depend on it:
assert isinstance(df.index, pd.DatetimeIndex)fails loudly at the source instead of 40 lines later. - Remember the
.dtrule: index →.month; column →.dt.month.
Confirm the dtype, convert to datetimes, pick the right accessor for index vs. column, and the error disappears.
Sources
Key takeaways
- •`.month`, `.year`, `.day` are datetime accessors — they exist only on a DatetimeIndex or a datetime Series, never on an integer index.
- •Check the type first: `df.index.dtype`. If it's int64, the index only looks like dates; it isn't stored as datetimes.
- •On an index use `.month` directly; on a column (Series) use `.dt.month`. Forgetting `.dt` is the second most common cause.
- •pandas 2.0 removed Int64Index/Float64Index/UInt64Index. Code that does `isinstance(idx, pd.Int64Index)` now raises AttributeError on `pd.Int64Index` itself.
- •Prevent it at load time: `pd.read_csv(path, parse_dates=['date'], index_col='date')` gives you a real DatetimeIndex from the start.
Frequently asked questions
Why does df.index.month fail when my index clearly contains dates?
Because the values are stored as integers or strings, not as pandas datetimes. An index that prints like 20230101 or '2023-01-01' can still have dtype int64 or object. Datetime accessors read the underlying datetime64 representation, which those dtypes don't have. Convert with pd.to_datetime first.
What's the difference between .month and .dt.month?
Use `.month` directly on a DatetimeIndex (df.index.month). Use `.dt.month` on a Series of datetimes (df['date'].dt.month) — the `.dt` accessor is how pandas exposes datetime properties on a column. Mixing them up gives you either this AttributeError or 'Can only use .dt accessor with datetimelike values'.
I got AttributeError: module 'pandas' has no attribute 'Int64Index'. Is that the same problem?
It's the pandas 2.0 version of it. Int64Index, Float64Index, and UInt64Index were removed in pandas 2.0 in favor of a single Index with a dtype. Replace isinstance(idx, pd.Int64Index) with pd.api.types.is_integer_dtype(idx), and upgrade any library (older statsmodels, scikit-learn, etc.) that still references the old classes.
How do I extract the month from a date column without touching the index?
Convert the column and use the .dt accessor: df['month'] = pd.to_datetime(df['date']).dt.month. This never involves the index, so an integer index is irrelevant.
Software Engineering Leader & Technical Author · Updated August 31, 2026