Skip to content

Commit a8e315e

Browse files
committed
Fix column order of dtypes
1 parent 112d126 commit a8e315e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pandas/io/stata.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1615,13 +1615,14 @@ def _do_select_columns(self, data, columns):
16151615
fmtlist = []
16161616
lbllist = []
16171617
matched = set()
1618-
for i, col in enumerate(data.columns):
1619-
if col in column_set:
1620-
matched.update([col])
1621-
dtyplist.append(self.dtyplist[i])
1622-
typlist.append(self.typlist[i])
1623-
fmtlist.append(self.fmtlist[i])
1624-
lbllist.append(self.lbllist[i])
1618+
data_column_list = data.columns.tolist()
1619+
for col in columns:
1620+
matched.update([col])
1621+
i = data_column_list.index(col)
1622+
dtyplist.append(self.dtyplist[i])
1623+
typlist.append(self.typlist[i])
1624+
fmtlist.append(self.fmtlist[i])
1625+
lbllist.append(self.lbllist[i])
16251626

16261627
self.dtyplist = dtyplist
16271628
self.typlist = typlist

0 commit comments

Comments
 (0)