Skip to main content
Post Reopened by Emi OB, Perry, user1114
Left closed in review as "Original close reason(s) were not resolved" by tripleee, Seon, NeilG
this question should not be marked as a duplicate: linked question is not about sorting
Added to review
Source Link
fantabolous
  • 22.9k
  • 8
  • 59
  • 52

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to sortsort the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to sort the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to sort the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

Reworded to clarify distinction between this question and the marked duplicate.
Source Link
William Miller
  • 10.4k
  • 4
  • 31
  • 50

Re-ordering Sorting columns in pandas dataframe based on column name

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to re-ordersort the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

Re-ordering columns in pandas dataframe based on column name

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to re-order the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

Sorting columns in pandas dataframe based on column name

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to sort the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

Post Closed as "Duplicate" by Sheldore python
deleted 16 characters in body; edited tags; edited title
Source Link
Georgy
  • 14k
  • 7
  • 70
  • 80

Python Pandas - Re-ordering columns in apandas dataframe based on column name

I have a dataframe with over 200 columns (don't ask why). The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to re-order the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within pythonPython?

Python Pandas - Re-ordering columns in a dataframe based on column name

I have a dataframe with over 200 columns (don't ask why). The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to re-order the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within python?

Re-ordering columns in pandas dataframe based on column name

I have a dataframe with over 200 columns. The issue is as they were generated the order is

['Q1.3','Q6.1','Q1.2','Q1.1',......]

I need to re-order the columns as follows:

['Q1.1','Q1.2','Q1.3',.....'Q6.1',......]

Is there some way for me to do this within Python?

added 2 characters in body
Source Link
piRSquared
  • 295.8k
  • 68
  • 512
  • 657
Loading
added 3 characters in body
Source Link
Aaron Hall
  • 401.7k
  • 94
  • 418
  • 342
Loading
Source Link
pythOnometrist
  • 6.9k
  • 8
  • 34
  • 51
Loading