[英]Pandas DataFrame column difference of max and min value
我想得到一列的最大和最小谷值的差。
range = DiabeticPatients.diff(DiabeticPatients['Glucose'].max() -
DiabeticPatients['Glucose'].min())
另外,想使用lambda進行更正。
使用.ptp()
(峰到峰)獲取最大-最小-最小:
In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: np.random.seed(444)
In [4]: df = pd.DataFrame({"Glucose": np.random.randint(0, 10000, size=100)})
In [5]: df['Glucose'].ptp()
Out[5]: 9947
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.