(df, columns)
| 49 | return df |
| 50 | |
| 51 | def cal_sentiment(df, columns): |
| 52 | for col in columns: |
| 53 | if "sentiment" not in col: |
| 54 | df[col] = df.groupby("timestamp")[col].transform("sum") |
| 55 | else: |
| 56 | df[col] = df.groupby("timestamp")[col].transform("mean") |
| 57 | df[col] = df[col].fillna(0.5) |
| 58 | return df |
| 59 | |
| 60 | |
| 61 | def cal_factor(df, level="day"): |