Home > other >  Reverse output col2 pandas
Reverse output col2 pandas

Time:10-18

The import numpy as np
The import pandas as pd
Myarray on=np. Array ([[1, 2, 3], [2 and 4], [three, four, five]])
Rowindex=[' row1 ', 'row2', 'row3]
Colname=[' col1, col2, col3 ']
Mydataframe=pd. DataFrame (data=https://bbs.csdn.net/topics/myarray, index=rowindex, columns=colname)

CodePudding user response:

The import numpy as np
The import pandas as pd

Myarray on=np. Array ([[1, 2, 3], [2 and 4], [three, four, five]])
Rowindex=[' row1 ', 'row2', 'row3]
Colname=[' col1, col2, col3 ']
Mydataframe=pd. DataFrame (data=https://bbs.csdn.net/topics/myarray, index=rowindex, columns=colname)
# print (mydataframe)
D=sorted (mydataframe [' col2], reverse=True)
Print (d)

Results:
[4, 3, 2)

CodePudding user response:

 myarray on=np. Array ([[1, 2, 3], [4] 2, [three, four, five]]) 
Rowindex=[' row1 ', 'row2', 'row3]
Colname=[' col1, col2, col3 ']
Mydataframe=pd. DataFrame (data=https://bbs.csdn.net/topics/myarray, index=rowindex, columns=colname)
Print (mydataframe [' col2] [: : 1])
  • Related