我有一个pandas
dataframe
列:
点击值的“视频”和“链接”
带有日期时间的索引。出于某种原因,当我在视频系列中使用符号学和箱线图时,我得到了错误
ValueError: Data has no positive values, and therefore can not be log-scaled.
但是当我在“链接”系列上这样做时,我可以正确绘制箱线图。
我已经验证了“视频”和“链接”系列都具有 NaN 值和正值。
关于为什么会发生这种情况的任何想法?以下是我为验证情况所做的工作
下面是示例代码:
#get all the not null values of video to show that there are positive
temp=a.types_pivot[a.types_pivot['video'].notnull()]
print temp
#get a count of all the NaN values to show both 'video' and 'link' has NaN
count = 0
for item in a.types_pivot['video']:
if(item.is_integer() == False):
count += 1
#try to draw the plots
print "there is %s nan values in video" % (count)
fig=plt.figure(figsize=(6,6),dpi=50)
ax=fig.add_subplot(111)
ax.semilogy()
plt.boxplot(a.types_pivot['video'].values)
这是视频系列代码的相关输出
输入链接视频 创建时间我运行相同的确切代码,除了我这样做
2011-02-10 15:00:51+00:00 NaN 5 2011-02-17 17:50:38+00:00 NaN 5 2011-03-22 14:04:56+00:00 NaN 5视频中有 5463 个 nan 值
a.types_pivot['link']
我能够绘制箱线图。
以下是链接系列的相关输出
索引:5269 个条目,2011-01-24 20:03:58+00:00 到 2012-06-22 16:56:30+00:00 数据列: 链接 5269 个非空值 照片 0 非空值 问题 0 非空值 状态 0 非空值 swf 0 非空值 视频 0 非空值 数据类型:float64(6)链接中有 216 个 nan 值
Using the describe function
a.types_pivot['video'].describe()
<pre>
count 22.000000
mean 16.227273
std 15.275040
min 1.000000
25% 5.250000
50% 9.500000
75% 23.000000
max 58.000000
</pre>