Skip to content

Commit b252376

Browse files
committed
add alternative ix when self.nlevel is 0
1 parent 360597c commit b252376

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pandas/io/formats/csvs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ def _save_chunk(self, start_i: int, end_i: int) -> None:
320320
res = df._get_values_for_csv(**self._number_format)
321321
data = list(res._iter_column_arrays())
322322

323-
ix = self.data_index[slicer]._get_values_for_csv(**self._number_format)
323+
ix = (
324+
self.data_index[slicer]._get_values_for_csv(**self._number_format)
325+
if self.nlevels != 0
326+
else np.full(end_i - start_i, None)
327+
)
324328
libwriters.write_csv_rows(
325329
data,
326330
ix,

0 commit comments

Comments
 (0)