pandas read_cs; matplotlib pyplot; sklearn

这篇博客介绍了如何利用pandas的read_csv函数读取以制表符分隔的CSV文件,并展示了使用sklearn进行岭迹图的绘制,强调了在处理包含逗号的CSV数据时需要注意的分隔符问题。
摘要由CSDN通过智能技术生成

如果含有中文或者英文长句子,里面很可能会有“,”,而CSV的逗号是分隔符(delimter,或Seperator)所以要加参数,把分隔符从逗号替换为‘\t’制表符

>>>pandas.read_csv('path',delimter='\t').head()

or

>>>file=pandas.read_csv('path',sep='\t')

>>>file.head()

 

from matplotlib import pyplot as plt
import numpy as np
import pandas as pd

hour=range(24)
viewers_hour = [30, 17, 34, 29, 19, 14, 3, 2, 4, 9, 5, 48, 62, 58, 40, 51, 69, 55, 76, 81, 102, 120, 71, 63]

plt.title('know nothing series')#title
plt.xlabel('Hour')#xlabel
plt.ylabel('Viewers')#ylabel
plt.plot(hour,viewers_hour)#x_data_source ,y_data_source
plt.legend(['legend1'])#图例
ax=plt.subplot()#在大的figure中可以建立多个axes
ax.set_facecolor('seashell')
ax.set_xticks(hour)#刻度
ax.set_yticks([0,20,40,60,80,100,120])#刻度
y_upper=[i+(i*0.05) for i in viewers
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值