Conditional Logic
General Info
Useful Snippets

10.0.12 Create a rank column

Example:

# Create an empty dataframe
DF = pd.DataFrame()
DF['A'] = [1,2,3]
DF['B'] = ['a','b', 'c']
DF['C'] = ['how',  'about','that']


# Create an index like column 'rank' to use as a label for the x-axis so that your chart looks pretty
DF_Sorted = DF.sort_values(['C'], ascending = True)
DF_Sorted.insert(0, 'rank', range(1, 1+len(DF_Sorted['C'])))