作者tuberosum (potato)
看板Python
標題[問題] 請問dataframe怎麼往前篩選
時間Sun Feb 5 18:01:20 2023
各位大神
請問一下
df=
date math
1. 10/20 80
2. 10/22 70
3. 10/24 87
4. 10/26 65
5. 10/30 90
假設是這樣 最新的一次數學分數是90
我要怎麼往前查找 最近一次分數>85 的index
我只想到篩選出大於df[df[math]>85] 然後用iloc[-2]
感覺好像有點笨笨的
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.230.41.199 (臺灣)
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Python/M.1675591282.A.6EA.html
2F:→ lycantrope: 這跟之前問過的有什麼不同#1ZC0t1K7? 02/05 23:05
3F:推 cspy: math 排序後就知道全部了~ 02/25 01:16