4. 探索分析
问题1:《如何用 R 绘制动态统计图》中
load('carriers_jan.RData')
就算与写的R文件放在同一文件夹下,系统报错说找不到文件;后面发现可以直接点RData文件载入Rstudio;或者采用整体路径导入
5.自然语言处理
前置小问题:用 conda install snownlp下载不了,发现conda里面没有这个包,因此应该用pip install才行
5.1 sentiment analysis
问题2:《如何用Python做舆情时间序列可视化?》中
from ggplot import *
报错:
AttributeError: module 'pandas' has no attribute 'tslib'
原因:ggplot太久没人去维护了,所以源码中没有做出相应的跟进。
ggplot(aes(x="date", y="sentiment"), data=df) + geom_point() + geom_line(color = 'blue') + scale_x_date(labels = date_format("%Y-%m-%d"))
D:\app\Anaconda\envs\test\lib\site-packages\ggplot\geoms\geom_point.py:58: UserWarning: FixedFormatter should only be used together with FixedLocator ax.set_xticklabels(new_ticks) D:\app\Anaconda\envs\test\lib\site-packages\ggplot\ggplot.py:232: UserWarning: FixedFormatter should only be used together with FixedLocator ax.xaxis.set_ticklabels(labels
绘制出来的图是这样的:
于是去找这个函数的用法:
1、df = ggplot(data, aes(x, y)) ,给参数data里传入数据,x里传入横坐标数据,y里传入纵坐标数据,即可画出一个空白框图;
2、geom_point(),散点图;
3、geom_line(),折线图;
4、geom_point() + geom_line(),折线散点图
函数用法没有问题的,那应该是出在函数本身
经过仔细分析,
发现单独用
geom_point()
geom_line(color = 'blue')
都是 可以得到类似的直线,只是point得到的x轴得到的坐标全是3986什么的,而line得到的x轴坐标得到的是2017
因此,下一步问题应该是解决为什么用point的横坐标是错误的,也就是
D:\app\Anaconda\envs\test\lib\site-packages\ggplot\geoms\geom_point.py:58: UserWarning: FixedFormatter should only be used together with FixedLocator ax.set_xticklabels(new_ticks) D:\app\Anaconda\envs\test\lib\site-packages\ggplot\ggplot.py:232: UserWarning: FixedFormatter should only be used together with FixedLocator
中的第58行(因为分别去掉后,第232行一直有报错),重点关注58行的那个py文件
###没往下想了,如果有知道的朋友可以帮忙看看orz
5.2 emotional analysis
1. 我使用了python的with open as f为什么还会出现FileNotFoundError,显示找不到文件(此时我把py文件和txt文件放在一个文件夹下)
后来找网上说用绝对路径可以(但我这个还是失败了)
解决方法是:原来用vscode打开的是这个文件夹的上一次层文件夹,当重新open folder到这层文件夹显示ok
2. NRC包不好下载
科学上网+改下载报错的时间
6.机器学习+深度学习
学过跳了,后面有空再来更新
7.爬虫
其中老师有个爬虫的网址是错的,去网上找老师的这篇文章有正确的网址