今天航空酒店研究了一早上+中午
了解了各种奖励配套
要好好optimize 一下
---
另外 jupyter notebook还真是个闹人的东西,但是还有common pattern
1. df[['a','b'.'c','d','e']].groupby(['a','b','c']).agg({'d':sum, 'e':list}) #dataframe
or df[['a','b'.'c','d','e']].groupby(['a','b','c'])['d'].agg([sum]) #series
2. df.apply(lambda x: fun(x['a']),axis=1)
3. df['a].apply(lambda x:fun(x))
4. df['a']=df['b'].shift(1)
5. df.sort_values(by=['a','b'])
6. pd.merge([df['a'],df['b']]) [concat]
7. pd.concat([df,df1]) (row, axis=1 for col)
8. dfa.merge(dfb, how='inner', on=['a','b'])
9. df.loc[df['a']>0]=df['a'] (assign value conditionally)
10. df['a']=pd.to_datetime(df['a'])
11. df.rolling('60d',on='time')['number'].mean()
12. df.set_index('date').asfreq('D') or df.set_index('date').resample('D').sum()
13. df['a'].fillna(method='ffill',inplace=True) (or 'bfill')
14. df['a'].groupby('b).apply(lambda x:
x.set_index("time).asfreq("D")).drop(['a'],axis=1).reset_index()
15. df['a'].groupby('b).apply(lambda x: x.set_index("time).resample("D").sum()).drop(['a'],axis=1).reset_index()
16. onehot encoding: pd.get_dummies(df, columns=['a'])
17. label encoding: pd.factorize(df['a'])[0]
No comments:
Post a Comment