用法:
DataFrame.pipe(func, *args, **kwargs)
應用
func(self, *args, **kwargs)
。- func:函數
應用於 Series/DataFrame/Index 的函數。
args
和kwargs
被傳遞到func
。或者(callable, data_keyword)
元組,其中data_keyword
是一個字符串,指示需要 Series/DataFrame/Index 的callable
的關鍵字。- args:可迭代的,可選的
傳遞給
func
的位置參數。- kwargs:映射,可選
傳遞給
func
的關鍵字參數字典。
- object:
func
的返回類型。
- object:
參數:
返回:
例子:
將需要 Series、DataFrames 或 GroupBy 對象的函數鏈接在一起時,請使用
.pipe
。而不是寫>>> func(g(h(df), arg1=a), arg2=b, arg3=c)
你可以寫
>>> (df.pipe(h) ... .pipe(g, arg1=a) ... .pipe(func, arg2=b, arg3=c) ... )
如果您有一個將數據作為(例如)第二個參數的函數,請傳遞一個元組,指示哪個關鍵字需要數據。例如,假設
f
將其數據作為arg2
:>>> (df.pipe(h) ... .pipe(g, arg1=a) ... .pipe((func, 'arg2'), arg1=a, arg3=c) ... )
相關用法
- Python cudf.DataFrame.pivot用法及代碼示例
- Python cudf.DataFrame.prod用法及代碼示例
- Python cudf.DataFrame.product用法及代碼示例
- Python cudf.DataFrame.pow用法及代碼示例
- Python cudf.DataFrame.mod用法及代碼示例
- Python cudf.DataFrame.isin用法及代碼示例
- Python cudf.DataFrame.rmul用法及代碼示例
- Python cudf.DataFrame.apply用法及代碼示例
- Python cudf.DataFrame.exp用法及代碼示例
- Python cudf.DataFrame.drop用法及代碼示例
- Python cudf.DataFrame.where用法及代碼示例
- Python cudf.DataFrame.median用法及代碼示例
- Python cudf.DataFrame.to_pandas用法及代碼示例
- Python cudf.DataFrame.take用法及代碼示例
- Python cudf.DataFrame.tail用法及代碼示例
- Python cudf.DataFrame.rfloordiv用法及代碼示例
- Python cudf.DataFrame.equals用法及代碼示例
- Python cudf.DataFrame.head用法及代碼示例
- Python cudf.DataFrame.count用法及代碼示例
- Python cudf.DataFrame.isna用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.DataFrame.pipe。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。