Closed answerquest closed 4 years ago
Traced to the root of the problem: under function replaceTableDB
,
there's a pandas .concat() statement without a sort parameter:
df3 = pd.concat([df,xdf], ignore_index=True)
And that makes pandas automatically sort all columns alphabetically. Documentation.
Need to set sort=False
So, changed the line to:
df3 = pd.concat([df,xdf], ignore_index=True, sort=False)
Changed .concat() statements at 3 other places as well.
Hope that fixes it.
Fixed in latest commit. Will close this when a proper release is done.
Operating system
Ubuntu / Linux
Python version
Python 3.6.5, Virtual environment.
Problem description
Ordering of columns in tables changes after we add a new item (in this case, see in trips) Console output:
In Delete ID page, we get a raw data preview and there we can see the trips table's columns ordering has now been sorted alphabetically:
This doesn't have an executive impact on our data; but it's annoying to have loaded in a GTFS with things sorted the way we wanted them; and then on exporting all the columns have been tosssed up.
Expected Action
Preserve the original columns order in the table when someone adds a new trip, route etc or edits one.