-
Notifications
You must be signed in to change notification settings - Fork 99
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
Update to use pandas 2.x #838
base: main
Are you sure you want to change the base?
Changes from all commits
7b850ca
002604d
8819b8c
be5c024
98bc2e4
5beffda
9b67fec
234a420
58003ed
012e92e
c6975a4
2a899e5
a752ea4
543b19a
8ed8fb9
50c9f6d
a393dbd
c06d737
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -714,7 +714,18 @@ def get_pyarrow( | |
if t is None: | ||
raise KeyError(tablename) | ||
if isinstance(t, pd.DataFrame): | ||
t = pa.Table.from_pandas(t, preserve_index=True, columns=columns) | ||
df = t | ||
try: | ||
t = pa.Table.from_pandas(df, preserve_index=True, columns=columns) | ||
except (pa.ArrowTypeError, pa.ArrowInvalid): | ||
# if there are object columns, try to convert them to categories | ||
df = df.copy() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw your latest comment about significantly longer run time with this PR. I noticed you are calling copy() here. In pandas 2.0 copy() defaults to a deep copy. I wonder if this contributed to the run time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is causing the problem. This code only executes in the |
||
for k, dtype in df.dtypes.items(): | ||
if dtype.kind == "O": | ||
df[k] = df[k].astype("str") | ||
elif dtype == "boolean": | ||
df[k] = df[k].astype("str") | ||
t = pa.Table.from_pandas(df, preserve_index=True, columns=columns) | ||
if isinstance(t, pa.Table): | ||
if columns is not None: | ||
t = t.select(columns) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My memory might be sloppy. Why possibly opting out sharrow for vehicle allocation?