python | April 09, 2020
example)
2.0, 3.5dataframe.rank(ascending = True) #오름차순
dataframe.rank(ascending = False) #내림차순
dataframe.rank(method = 'average')
0 1.0
1 2.0
2 3.5
3 3.5
4 5.0
dataframe.rank(method = 'min')
0 1.0
1 2.0
2 3.0
3 3.0
4 5.0
dataframe.rank(method = 'max')
0 1.0
1 2.0
2 4.0
3 4.0
4 5.0
dataframe.rank(method = 'first')
0 1.0
1 2.0
2 3.0
3 4.0
4 5.0
import pandas as pd
rank_table = pd.DataFrame(ranking_list.values())
ordered_table = rank_table.sort_values('average_time', ascending = True)
ordered_table['total_score_rank'] = ordered_table['total_score'].rank(ascending = False, method = 'min')
ordered_table['total_count_rank'] = ordered_table['total_count'].rank(ascending = False, method = 'min')
ordered_table['completion_score_rank'] = ordered_table['completion_score'].rank(ascending = False, method = 'min')
ordered_table['average_time_rank'] = ordered_table['average_time'].rank(ascending = True, method = 'min')
ordered_table['shortest_time_rank'] = ordered_table['shortest_time'].rank(ascending = True, method = 'min')
Reference
: [Python] Pandas - DataFrame 관련 메서드