Python学习笔记
铁拳小杨哥
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
常用的列表转DataFrame对象的方法
方法1:直接通过pandas的DataFrame函数 方法2:先通过pandas的DataFrame函数创建一个空的DataFrame对象,再通过索引的方式添加数据 方法3:通过字典的方式创建DataFrame对象原创 2022-06-27 22:38:00 · 6174 阅读 · 1 评论 -
Python 列表(数组) 获取最大/最小几个值及其下标
import heapq arr = [20,100,2,3,1,0,1000,156,30,7] ##求最大的5个值 arr_max = heapq.nlargest(5,arr)#获取前五大的值并排序 index_max = map(arr.index,arr_max)#获取前五大的值下标 print(arr_max) print(list(index_max))#map生成的对象要转化成为list才能输出 ##求最小的5个值 arr_min = heapq.nsmallest(5,arr)#获取原创 2022-04-18 17:16:51 · 8733 阅读 · 6 评论
分享