Here is my pandas.DataFrame :
import pandas as pd data = pd.DataFrame({ 'first': [40, 32, 56, 12, 89], 'second': [13, 45, 76, 19, 45], 'third': [98, 56, 87, 12, 67] }, index = ['first', 'second', 'third', 'fourth', 'fifth'])
I want to create a new DataFrame that will contain the top 3 values from each column of my data DataFrame .
Here is the expected result:
first second third 0 89 76 98 1 56 45 87 2 40 45 67
How can i do this?
python pandas dataframe
Michael vayvala
source share