我在dataframe中有几个列有NaN值。因此,当我试图创建一个包含多个列的线图时,这些图会突然开始。我如何避免这种情况?用零填充数据集中的NaN值?或者还有别的办法吗?在
看红线!在
代码
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(70,40))
ax = fig.add_subplot(1, 1, 1)
ax.tick_params(direction='out', length=10, width=3,labelsize=35)
group_combined.plot(ax=ax,x='Date',y=['column1','collumn2'],linewidth=7.0)
ax.set_xlabel("date",size=40)
ax.set_ylabel("Number of orders",size=40)
ax.set_title("Distribution of orders over the month",size=50)
在我的数据中,没有NaN。对于一些专栏,对于最初的几个日期,NaN's可能会出现。一旦价值开始出现,就不会有任何问题。在
Python版本:3.6 Matplotlib版本:2.0.0
以下是使用
numpy
删除nan的方法:结果如下: 左图显示了带有nan的数据,而在右侧,它们被删除了。在
相关问题 更多 >
编程相关推荐