2 回答

TA貢獻(xiàn)1840條經(jīng)驗 獲得超5個贊
嘗試,并計算時間,畢竟print(ddf.head(10))要看輸出
from dask import dataframe as dd
ddf = dd.from_pandas(df, npartitions=10)
ddf[(ddf.A == 2) | (ddf.A == 1)]['C'] = ddf['A']
ddf[(ddf.A != 2) & (ddf.A != 1)]['C'] = ddf['B']
print(ddf.head(x))

TA貢獻(xiàn)2039條經(jīng)驗 獲得超8個贊
最終如下:
cond = df.met.isin(['Bus. Hours', 'Offshift'])
df['met'] = np.where(cond, np.nan, df['met'])
df['time'] = np.where(cond, df['met'], df['time'])
遇到需要這樣做的另一種情況。它沿著不應(yīng)包含子字符串的字符串行:
df1 = dataset.copy(deep=True)
df1['F_adj'] = 0
cond = (df1['Type'] == 'Delayed Ignition') | ~(df1['Type'].str.contains('Delayed'))
df1['F_adj'] = np.where(cond,df1['F'], 0)
添加回答
舉報