Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

reverse row order pandas

import pandas as pd

df = pd.DataFrame({'a':[1,2,3],
                   'b':[4,5,6,],
                   'c':[7,8,9,]})

df_col_reversed = df.loc[:, ::-1] # reverse column order
df_row_reversed = df.loc[::-1, :] # reverse row order
Comment

reverse order of dataframe rows

# Reverse row order
data_reversed = data[::-1]  
Comment

PREVIOUS NEXT
Code Example
Python :: python check if variable is iterable 
Python :: django create empty migration 
Python :: how to separate year from datetime column in python 
Python :: blank lines with csv.writer 
Python :: plt vertical line 
Python :: display np array as image 
Python :: python string argument without an encoding 
Python :: matplotlib get rid of gridlines 
Python :: python numpy installation 
Python :: print today time python 
Python :: selenium python enter text 
Python :: discord.py ban 
Python :: matplotlib marker hollow circle 
Python :: send message to specific channel discord.py 
Python :: pandas groupby column count distinct values 
Python :: open image in numpy 
Python :: How to perform run-length encoding in Python? 
Python :: django versatileimagefield 
Python :: correlation between lists python 
Python :: python random number 
Python :: how to clear a command line python 
Python :: select closest number in array python 
Python :: get image height width cv2 
Python :: pandas change dtype to string 
Python :: list all virtualenv in python 
Python :: how to create dynamic variable names in python 
Python :: first position dict python 
Python :: visualize correlation matrix python 
Python :: inverse matrix numpy 
Python :: discord.py dm specific user 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =