给网友们整理相关的编程文章,网友厍德厚根据主题投稿了本篇教程内容,涉及到pandas 列降序、pandas 降序、pandas 列降序相关内容,已被159网友关注,如果对知识点想更进一步了解可以在下方电子资料中获取。
pandas 列降序
升序
import pandas as pd import numpy as np data = np.random.randint(low=2,high=10,size=(5,3)) data2 = np.random.randint(low=2,high=10,size=(5,3)) df1 = pd.DataFrame(data,columns=["a","b","c"],index=range(5)) df2 = pd.DataFrame(data2,columns=["a","b","c"],index=range(5)) df1 = df1.sort_values(by=['a','b']) print(df1)
运行结果:
降序
import pandas as pd import numpy as np data = np.random.randint(low=2,high=10,size=(5,3)) data2 = np.random.randint(low=2,high=10,size=(5,3)) df1 = pd.DataFrame(data,columns=["a","b","c"],index=range(5)) df2 = pd.DataFrame(data2,columns=["a","b","c"],index=range(5)) df1 = df1.sort_values(by=['a','b'], ascending=[False, False]) print(df1)
运行结果:
PS: 先按a降序,再按b降序
到此这篇关于pandas按某列降序的实现的文章就介绍到这了,更多相关pandas 列降序内容请搜索码农之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持码农之家!