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

pd.concat with names=None #883

Closed
amgcc opened this issue Feb 28, 2024 · 5 comments · Fixed by #894
Closed

pd.concat with names=None #883

amgcc opened this issue Feb 28, 2024 · 5 comments · Fixed by #894
Assignees
Labels
good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@amgcc
Copy link
Contributor

amgcc commented Feb 28, 2024

Describe the bug
pd.concat should accept names=None as it is the default value.

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
def maybe_concat(
    dd: dict[str, pd.DataFrame], names: list[str] | None = None
) -> pd.DataFrame:
    """Concatenate a dict of dataframes if available."""
    return pd.concat(dd, names=names) if dd else pd.DataFrame()
  1. Indicate which type checker you are using (mypy or pyright).
    mypy
  2. Show the error message received from that type checker while checking your example.
error: Argument "names" to "concat" has incompatible type "list[str] | None"; expected "list[str]"  [arg-type]

Please complete the following information:

  • OS: [e.g. Windows, Linux, MacOS] Linux
  • OS Version [e.g. 22] Fedora 7
  • python version 3.11.8
  • version of type checker 1.8.0
  • version of installed pandas-stubs 2.1.4
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Feb 28, 2024

Yes, that's an error. Easy fix to add the | None to the names argument in pandas-stubs/core/reshape/concat.pyi PR with tests welcome.

@Dr-Irv Dr-Irv added good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Feb 28, 2024
@amgcc
Copy link
Contributor Author

amgcc commented Feb 28, 2024

Ill try and tackle this.

@Aftabby
Copy link
Contributor

Aftabby commented Mar 21, 2024

Hello, @Dr-Irv
I'm assigning the issue to myself, as it seems no one else has done any improvement on it yet.

@Aftabby
Copy link
Contributor

Aftabby commented Mar 21, 2024

take

@Aftabby
Copy link
Contributor

Aftabby commented Mar 22, 2024

Hello @Dr-Irv ,
Will you kindly check if issue has been solved with #894 or not?

Dr-Irv pushed a commit that referenced this issue Mar 22, 2024
* Fixed TYP of names argument of concat method and included test

Pointing to the issue #883

* Removed the duplicate test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants