-
Notifications
You must be signed in to change notification settings - Fork 416
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
Pandas import error when merging tables #2112
Labels
Comments
Yeah, the top-level import is missing apparently so if you import pandas without alias it works, but this needs to be fixed by adding the same lines as in the writer and then if _has_pandas and isinstance(df, pl.Dataframe): try:
import pandas as pd # noqa: F811
except ModuleNotFoundError:
_has_pandas = False
else:
_has_pandas = True If you want, you can open a PR for it :) |
Alright, thanks! I'll have a quick look at it tonight. |
ion-elgreco
added a commit
that referenced
this issue
Jan 27, 2024
# Description Pandas was only imported for static type checking, but was actually used in the code of the module leading to import errors. Added the import similarly to `writer.py`, and updated the pandas alias in the type hints from 'pandas' to 'pd'. # Related Issue(s) - closes #2112 # Documentation x Co-authored-by: Tim Haarman <[email protected]> Co-authored-by: Ion Koutsouris <[email protected]>
RobinLin666
pushed a commit
to RobinLin666/delta-rs
that referenced
this issue
Feb 2, 2024
# Description Pandas was only imported for static type checking, but was actually used in the code of the module leading to import errors. Added the import similarly to `writer.py`, and updated the pandas alias in the type hints from 'pandas' to 'pd'. # Related Issue(s) - closes delta-io#2112 # Documentation x Co-authored-by: Tim Haarman <[email protected]> Co-authored-by: Ion Koutsouris <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Local
Delta-rs version:
v0.15.1
Binding:
Python
Environment:
Bug
What happened:
Trying to get the merging example from the docs, but using pandas instead of pyarrow for the tabkle. This gives a
NameError
that pandas is not defined, as in thetable.py
pandas is only imported when type checking:delta-rs/python/deltalake/table.py
Line 941 in 1a984ce
As per my limited understanding of this construct, pandas is only imported for static type checking. But seeing as it is actually used in the code, should it be imported normally?
What you expected to happen:
That the pandas dataframe gets merged in the existing delta table :).
How to reproduce it:
Using the example from the docs, but with a pandas DataFrame instead of a pyarrow table:
results in:
NameError: name 'pandas' is not defined
More details:
I'm not very familiar with static type checking or this code, so please let me know if I did something wrong and this is not a bug!
The text was updated successfully, but these errors were encountered: