網站首頁 編程語言 正文
升序
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降序
原文鏈接:https://blog.csdn.net/weixin_40959890/article/details/128634507
相關推薦
- 2022-04-20 Appium自動化測試中獲取Toast信息操作_python
- 2023-01-13 pytorch如何定義新的自動求導函數(shù)_python
- 2024-04-05 idea使用docker生成鏡像(打包鏡像,導入鏡像,導出鏡像)
- 2022-07-26 tensorflow 加載模型時 報錯: ValueError: No variables to s
- 2023-01-12 python列表添加元素append(),extend(),insert(),+list的區(qū)別及說明
- 2022-09-10 Python自動打印被調用函數(shù)變量名及對應值?_python
- 2023-01-04 C++無try-catch的異常捕獲示例詳解_C 語言
- 2022-09-08 Go語言中的Struct結構體_Golang
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學習環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結構-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支