NumPy and Matplotlib

Load csv file, before load file, make sure put the file in the same folder.
EXAMPLE:
data = np.loadtxt(“file.csv”,usecols = (0),unpack = True , skiprows = 1, delimiter =’,’, dtype= ‘str’)

data_1 = np.loadtxt(“file.csv”,usecols = (1,2),unpack = True , skiprows = 1, delimiter =’,’, dtype= ‘int’)

picture:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline (先写这三行)
引入数学计算外借库,和画图外借库

alldata=np.loadtxt(“file1”,usecols=(0,1),skiprows=1, delimiter=’,’)

*(意思是写个list名字叫alldata,然后np.loadtxt, 第一个元素是文件名称,然后可用列数是第0和1就是前两列,skiprow是指跳过第一行名称行。Delimiter间隔用逗号,用引号来框起来‘,’)

这个就是excel里第一列第二列分开写法,mhu-data, mhu-level再重复上一步
那么你在下一行写alldata,就会显示出一个()里有两个数据,分别是年份和对应的数据。
(我们希望能把所有年份的对应数据都抽出来放到一个list里。那么: mhu_date, mhu_level = np.loadtxt(“lake_mhu.csv”, usecols = (0,1), unpack=True, skiprows = 1, delimiter=’,’) 再写一行,还是那个文件,但是要起个新名字再load,里面多加一个拆包unpack=true。)
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值