Pytorch 随笔0711

进入这里
在这里插入图片描述

输入如下语句

conda activate env_pytorch
python
import torch

书P26 2.2.1 读取数据集

然后进入pytorch 数据操作

先打开python
>>>import torch
>>>import os

>>>os.makedirs(os.path.join('E:', 'data'), exist_ok=True)
>>>data_file = os.path.join('E:', 'data', 'house_tiny.csv')
>>>with open(data_file, 'w') as f:
...     f.write('NumRooms,Alley,Price\n')
...     f.write('NA,Pave,127500\n')
...     f.write('2,NA,106000\n')
...     f.write('4,NA,178100\n')
...     f.write('NA,NA,140000\n')

//运行出结果

>>>exit()  //退出python
(env_pytorch) C:\Users\杨珊>pip install pandas
//下面是漫长的安装等待时间

漫长等待后,安装失败,看别的帖子说:

在cmd中执行命令
pip install pandas -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

用豆瓣源进行安装
原因:这种情况是因为默认从国外服务器下载的,网速很慢,就会连接超时,用国内源安装就可以

果然成功了:
在这里插入图片描述
安崇成功,重新输入

(env_pytorch) C:\Users\杨珊>python
Python 3.7.16 (default, Jan 17 2023, 16:06:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.makedirs(os.path.join('E:', 'data'), exist_ok=True)
>>>> data_file = os.path.join('E:', 'data', 'house_tiny.csv')
>>> with open(data_file, 'w') as f:
...     f.write('NumRooms,Alley,Price\n')
...     f.write('NA,Pave,127500\n')
...     f.write('2,NA,106000\n')
...     f.write('4,NA,178100\n')
...     f.write('NA,NA,140000\n')
21
15
12
12
13

>>> data=pd.read_csv(data_file)
>>> print(data)
   NumRooms Alley   Price
0       NaN  Pave  127500
1       2.0   NaN  106000
2       4.0   NaN  178100
3       NaN   NaN  140000
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT__shan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值