Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sort dataframe by function

df = pd.DataFrame(['bit_0', 'bit_2', 'bit_5'], columns=['bit'])
df.sort_values('bit' ,key=lambda x: x.str.split("_",expand=True)[1].astype(int))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #dataframe #function
ADD COMMENT
Topic
Name
5+8 =