Skip to content

CLN: avoid Block.get_values in io.sql #32524

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

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pandas/io/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,16 @@ def insert_data(self):
else:
# convert to microsecond resolution for datetime.datetime
d = b.values.astype("M8[us]").astype(object)
elif b.is_timedelta:
# numpy converts this to an object array of integers,
# whereas b.astype(object).values would convert to
# object array of Timedeltas
d = b.values.astype(object)
else:
d = np.array(b.get_values(), dtype=object)
# TODO(2DEA): astype-first can be avoided with 2D EAs
# astype on the block instead of values to ensure we
# get the right shape
d = b.astype(object).values

# replace NaN with None
if b._can_hold_na:
Expand Down