2021-03-25 python数据处理系统学习(六)数据分析常用库(基础)

2021-03-25 python数据处理系统学习(六)数据分析常用库(基础)

1、Numpy

import numpy as np
a=np.array([1,2,3,4])
type(a)
Out[1]: numpy.ndarray

print(a[1])
print(a[-1])
print(a.min())
print(a.max())
2
4
1
4


b=np.array([[1,2,3,4],[5,6,7,8]])

b*b
Out[6]: 
array([[ 1,  4,  9, 16],
       [25, 36, 49, 64]])

from numpy import size#求数组元素个数
size([1,2,3,4])
Out[21]: 4

2、pandas

import pandas as pd
s=pd.Series([1,2,3],index=['a','b','c'])

type(s)
Out[9]: pandas.core.series.Series

data=pd.DataFrame([[1,2,3],[4,5,6]],columns=['a','b','c'])
data
Out[11]: 
   a  b  c
0  1  2  3
1  4  5  6

可以用read函数获得excel表格,用head函数读取表格的前五行

3、matplotlib

import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,1000)
x
y=np.sin(x)
plt.plot(x,y,label='y=sinx',color='red')

在这里插入图片描述


import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,10,1000)
x
y=np.sin(x)
plt.plot(x,y,label='y=sinx',color='red',linewidth=2)
plt.xlabel('times')
plt.ylabel('vol')
plt.title('y=sinx')
plt.legend(loc='center')
plt.show()

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值