【发布时间】:2018-07-25 10:25:23
【问题描述】:
我正在尝试在散点图中绘制一系列 IP 地址,然后根据它们的“检测”标记它们,它们是 0 或大于 0.
尽管确实生成了此图,但它对所有点的颜色相同,而不是通过恶意标签将它们分开,非常感谢任何帮助!
df = pd.io.sql.read_sql('SELECT Date_scanned, IP, Detections FROM URLs', con=conn)
df['Date_scanned']=df['Date_scanned'].str.split(" ").str[0]
detections = df['Detections'].values
for row in df:
for x in detections:
if x > 0:
malicious = "Yes"
else:
malicious = "No"
plt.scatter(df['Date_scanned'], df['IP'], label=malicious)
plt.legend(loc='best')
plt.show()
【问题讨论】:
-
如果没有Minimal, Complete, and Verifiable example,很难提供完整的答案请提供模型数据,特别是查看How to make good reproducible pandas examples
标签: python pandas matplotlib scatter-plot