Pandas學習筆記 05 資料篩選 過濾

2021-10-02 02:21:09 字數 2199 閱讀 1398

1. excel處理

選中原始資料---排序和篩選/篩選---選中c1列的下拉箭頭/自定義篩選方式,設定大於等於18/小於30---確定,即可實現顯示大於等於18歲,小於30歲的學生的成績。

繼續篩選,在年齡18-30中,選出分數大於85的學生

選中d2的下拉列表,選擇數字篩選/大於/85

獲取資料

選出年齡段在18-30之間的學生成績

繼續篩選得分在85以上的

換一種寫法,效果相同

import pandas as pd

def age_18_to_30(a):

return 18<=a<30

def level_a(s):

return 85<=s<=100

students = pd.read_excel("c:/tmp/student.xlsx",index_col='id')

print(students)

再換一種寫法,使用lambda表示式

import pandas as pd

# def age_18_to_30(a):

# return 18<=a<30

# def level_a(s):

# return 85<=s<=100

students = pd.read_excel("c:/tmp/student.xlsx",index_col='id')

print(students)

對**太長的**進行換行,用正斜線,回車

import pandas as pd

# def age_18_to_30(a):

# return 18<=a<30

# def level_a(s):

# return 85<=s<=100

students = pd.read_excel("c:/tmp/student.xlsx",index_col='id')

print(students)

大資料學習筆記(05)

大資料學習筆記 05 nginx配置 master processes 只有乙個 worker processes 1 工作程序數,預設為1,可以改為auto,即啟動與cpu核數相同的worker程序 tengine worker connections 單個worker processes最大的併...

pandas學習 Task05合併

問題二 merge ordered和merge asof的作用是什麼?和merge是什麼關係?merge ordered 根據官方說明,適用與帶時間序列的資料,自帶ffill bfill 引數,可以方便填充 merge asof 模糊匹配版的merge 問題三 請構造乙個多級索引與多級索引合併的例子...

pandas學習筆記

import numpy as np import pandas as pd obj2 pd.series 4,7,5,3 index d b a c obj2 out 99 d 4 b 7 a 5 c 3 dtype int64 a b pd.series a bout 102 a 1 b 2 c...