我的目标是为数据中的每一列及其相应的滚动平均值创建时间序列图。我希望子图之间的线条颜色不同。例如,对于第二个子图中的gym 和rolling_mean_gym,线条的颜色应为紫色和红色。我该怎么做呢?
当我在plot()中设置颜色选项时,它会更改原始数据图和滚动平均图的颜色,这并不理想。
我通过使用以下代码计算时间序列每列的滚动平均值来创建下图:
# calculate rolling mean
def rolling_mean(col):
rolling_mean_col = 'rolling_mean_{}'.format(col)
df[rolling_mean_col] = df[col].rolling(12).mean()
# create rolling mean columns
cols = ['diet', 'gym', 'finance']
for col in cols:
rolling_mean(col)
# plot data in subplots
fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(13,10));
df[['diet', 'rolling_mean_diet']].plot(ax=axes[0]);
df[['gym', 'rolling_mean_gym']].plot(ax=axes[1]);
df[['finance', 'rolling_mean_finance']].plot(ax=axes[2]);
Run Code Online (Sandbox Code Playgroud)
类似地(-1 == - 1&1 == 1)也是假的.
如果这是显而易见的事情而道歉,但我无法找到解释.
我在 Mac 上使用 Parallels 来运行 Windows 8.1 操作系统。Parallels 有一个怪癖,每次重新启动时都会将屏幕分辨率重置为最高级别。因此,我想编写一个简短的 Powershell 脚本,它会自动将我的屏幕分辨率设置为我喜欢的分辨率。问题是,使用Set-ScreenResolution或Set-DisplayResolution给我以下错误:
Set-DisplayResolution :术语“Set-DisplayResolution”不被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。在行:1 char:1 + Set-DisplayResolution + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-DisplayResolution:String) [], CommandNotFoundException + FullQualifiedErrorId : CommandNotFoundException
知道为什么会这样吗?
我使用的是 Windows 8.1 64 位。我的 Powershell 版本是 4.0。我在 Yosemite 操作系统 (mac) 上使用 Parallels 9 作为我的虚拟机。