1.如何解决使用pip install 显示read time out?
其一:
pip --default-timeout=100 install -U 库名
例如:
pip --default-timeout=100 install -U numpy
其二:
包源镜像:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 库名
例如:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy
2.如何优雅地打开ipynb文件?
使用pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter下载jupyter
控制台(win+R)输入命令:pip show jupyter可查看路径
进入anaconda安装包下的scripts目录
ctrl+f搜索notebook出现
找到一个ipynb文件选择打开方式:为jupyter-notebook.exe 并设置默认,
双击之后,奇迹发生了
.ipynb可以直接运行,运行之后跳出命令行窗口,会自动打开这个.ipynb对应的网页!
3.如何读取json文件?
读取json数据并保存为csv文件
data_str = open('filename.json').read()
df = pd.read_json(data_str,orient = 'records')
print(df.head(5))
outputpath='E:data\filename.csv'
df.to_csv(outputpath,sep=',',index=False,header=False)
4.reset_index(inplace=True,drop=True)
df.reset_index() #将会将原来的索引index作为新的一列
使用drop参数设置去掉原索引