Skip to content

Commit abdae04

Browse files
jbrockmendelSeeminSyed
authored andcommitted
CLN: avoid Block.get_values in io.sql (pandas-dev#32524)
1 parent 88a471a commit abdae04

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pandas/io/sql.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,16 @@ def insert_data(self):
705705
else:
706706
# convert to microsecond resolution for datetime.datetime
707707
d = b.values.astype("M8[us]").astype(object)
708+
elif b.is_timedelta:
709+
# numpy converts this to an object array of integers,
710+
# whereas b.astype(object).values would convert to
711+
# object array of Timedeltas
712+
d = b.values.astype(object)
708713
else:
709-
d = np.array(b.get_values(), dtype=object)
714+
# TODO(2DEA): astype-first can be avoided with 2D EAs
715+
# astype on the block instead of values to ensure we
716+
# get the right shape
717+
d = b.astype(object).values
710718

711719
# replace NaN with None
712720
if b._can_hold_na:

0 commit comments

Comments
 (0)