![](/img/trans.png)
[英]Pass multiple column names as input to the parameter index_col using the function dask.dataframe.read_sql_table to create a dask dataframe
[英]How to correctly input dask Dataframe as parameter to a function?
當我將Dask Dataframe作為參數傳遞時,他正在轉換為pandas Dataframe。
print(type(sellout_df))
simulate_sku_predictions(sellout_df.loc[(sellout_df['sku'] == sku) & (sellout_df['store_id'] == store)].compute(), store, sku)
打印=> <class 'dask.dataframe.core.DataFrame'>
輸入定義的功能
def simulate_sku_predictions(sellout_sku_df, store, sku):
print(type(sellout_sku_df))
打印=> <class 'pandas.core.frame.DataFrame'>
我不能使用計算和快捷功能。
我是個新手,但是如果“我不必”,我認為在代碼中間進行轉換是不合適的。
dask.DataFrame.compute()
返回Pandas DataFrame 。 因此,該代碼不被傳遞DASK數據幀到simulate_sku_predictions
。 論據
sellout_df.loc[(sellout_df['sku'] == sku) & (sellout_df['store_id'] == store)].compute()
在將Pandas DataFrame作為simulate_sku_predictions
的參數傳遞之前,先將其評估。
如果您刪除調用compute()
然后sellout_df.loc[...]
將是一個DASK數據框,你可以傳遞到simulate_sku_predictions
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.