Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support python3.13 #1910

Open
2 of 3 tasks
sakosha opened this issue Feb 13, 2025 · 3 comments
Open
2 of 3 tasks

Support python3.13 #1910

sakosha opened this issue Feb 13, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@sakosha
Copy link

sakosha commented Feb 13, 2025

Describe the bug
TypeError when using pd.concat on pandera.typing.DataFrame after merge.

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of pandera.
  • (optional) I have confirmed this bug exists on the main branch of pandera.

Code Sample

# hello.py
from __future__ import annotations

import datetime as dt

from pandera.dtypes import Date
from pandera.dtypes import DateTime
from pandera.typing import DataFrame
from pandera.typing import Series

import pandas as pd
import pandera as pda


class InDataFrameModel(pda.DataFrameModel):
    time: Series[DateTime]
    id: Series[int]


class OutDataFrameModel(pda.DataFrameModel):
    id: Series[int]
    date: Series[Date]
    count: Series[int]


def get_summary_dataframe(
    *, dataframe: DataFrame[InDataFrameModel]
) -> DataFrame[OutDataFrameModel]:
    dataframe['date'] = dataframe['time'].dt.date
    summary = (
        dataframe.groupby(by=['id', 'date'])
        .agg(count=('time', 'nunique'))
        .reset_index()
    )

    brand_infos_df = pd.DataFrame([dict(id=1)])

    return DataFrame[OutDataFrameModel](
        summary.merge(brand_infos_df, on='id', how='left')
    )


if __name__ == '__main__':
    dataframe = DataFrame[InDataFrameModel]({
        'time': [dt.datetime(2024, 1, 1)],
        'id': [1],
    })
    dfs: list[DataFrame[OutDataFrameModel]] = [get_summary_dataframe(dataframe=dataframe) for _ in range(10)]

    pd.concat(dfs)

and I get this traceback:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/sanzhar/PycharmProjects/ASSP/hello.py", line 47, in <module>
    dfs: list[DataFrame[OutDataFrameModel]] = [get_summary_dataframe(dataframe=dataframe) for _ in range(10)]
                                               ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/sanzhar/PycharmProjects/ASSP/hello.py", line 28, in get_summary_dataframe
    dataframe['date'] = dataframe['time'].dt.date
                        ~~~~~~~~~^^^^^^^^
  File "/home/sanzhar/PycharmProjects/ASSP/.venv/lib/python3.13/site-packages/pandas/core/frame.py", line 4070, in __getitem__
    is_mi = isinstance(self.columns, MultiIndex)
                       ^^^^^^^^^^^^
  File "properties.pyx", line 66, in pandas._libs.properties.AxisProperty.__get__
TypeError: 'NoneType' object is not subscriptable

Expected behavior

No output, No error.

Desktop:

  • OS: ubuntu 24.04.2 LTS
  • Python 3.13.2 & 3.13.0
  • pandera 0.22.1

to reproduce

to get an error:
(.venv) uv sync --python 3.13 && python -m hello

prior to 3.13:
(.venv) uv sync --python 3.12 && python -m hello

@sakosha sakosha added the bug Something isn't working label Feb 13, 2025
@cosmicBboy
Copy link
Collaborator

Hi @sakosha, pandera does not officially support python 3.13 yet, there are changes in the base python typing system that pandera needs to conform to in order to make this work

@sakosha
Copy link
Author

sakosha commented Feb 14, 2025

Thank you for the reply! Should I close this and open a separate issue about 3.13 support?

@cosmicBboy
Copy link
Collaborator

Feel free to change the title of this issue

@sakosha sakosha changed the title different behavior between 3.12 and 3.13 Support python3.13 Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants