Skip to content

Commit 98afb7f

Browse files
FIX-#6204: Use reset_index instead of insert in to_sql (#6205)
Signed-off-by: Devin Petersohn <devin.petersohn@gmail.com>
1 parent 0fbd19b commit 98afb7f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

modin/pandas/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,9 +3360,13 @@ def to_sql(
33603360
new_query_compiler = self._query_compiler
33613361
# writing the index to the database by inserting it to the DF
33623362
if index:
3363-
if not index_label:
3364-
index_label = "index"
3365-
new_query_compiler = new_query_compiler.insert(0, index_label, self.index)
3363+
new_query_compiler = new_query_compiler.reset_index()
3364+
if index_label is not None:
3365+
if not is_list_like(index_label):
3366+
index_label = [index_label]
3367+
new_query_compiler.columns = list(index_label) + list(
3368+
new_query_compiler.columns[len(index_label) :]
3369+
)
33663370
# so pandas._to_sql will not write the index to the database as well
33673371
index = False
33683372

0 commit comments

Comments
 (0)