![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据处理
weixin_44340026
这个作者很懒,什么都没留下…
展开
-
pandas.DataFrame操作(一)创建
Pandas DataFrame的用法记录pandas.DataFrame( data=None, # ndarray (structured or homogeneous), Iterable, dict, or DataFrame index=None, # Index or array-like columns=None, # Index or array-like dtype=None, # dtype, default None copy=False # bool, defau原创 2021-06-11 17:24:52 · 113 阅读 · 0 评论 -
pandas.DataFrame操作(二)索引、切片
系列课题:pandas.DataFrame操作(二)索引、切片df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])# 原始:""">>>df a b c0 1 2 31 4 5 62 7 8 9"""# 行索引:""">>>df.loc[0]a 1b原创 2021-06-11 17:24:02 · 326 阅读 · 0 评论 -
OpenPyXL读写.xlsx文件
本文介绍Python对.xlsx文件的读写操作预期的效果:打开、读取、生成、写入、保存官方docs: https://openpyxl.readthedocs.ioInstallationpip install openpyxl1. 打开已有.xlsxfrom openpyxl import load_workbookwb = load_workbook("campaign.xlsx")ws = wb["Results"]2. 读取内容获取某张sheet:# 获取所有sheet名原创 2021-06-11 17:22:21 · 122 阅读 · 0 评论 -
Pandas读写.xlsx文件
研究对象:pandas.read_excel( io, # str, bytes, ExcelFile, xlrd.Book, path object, or file-like object sheet_name=0, # str, int, list, or None, default 0 header=0, # int, list of int, default 0 也可以设为None names=None, # array-like, default None 要使用的列名列表原创 2021-06-11 17:21:35 · 748 阅读 · 0 评论 -
NumPy(4)矩阵、随机数、打乱
NumPy(三)矩阵和随机数:矩阵——np.matrixmatrix(字符串/列表/元组/数组)mat(字符串/列表/元组/数组)>>>a = np.mat('1 2 3; 4 5 6')>>>amatrix([[1, 2, 3], [4, 5, 6]])>>>a = np.mat([[1, 2, 3], [4, 5, 6]])>>>amatrix([[1, 2, 3], [4, 5原创 2021-06-10 00:50:27 · 655 阅读 · 0 评论 -
NumPy(3)运算:求和、堆叠
系列课题:NumPy(二)运算2求和函数sum():对数组中所有元素求和>>>a = np.arange(4)>>>aarray([0, 1, 2, 3])>>>np.sum(a)6# 按行或列求和# 轴(axes):数组中的每一个维度被称为一个轴。# 秩(rank):轴的个数。(与线性代数中的秩不一样)>>>b = np.arange(12).reshape(3, 4)>>>barray([原创 2021-06-10 00:49:39 · 252 阅读 · 0 评论 -
NumPy(2)运算
课题:NumPy(二)运算np.reshape(shape) # 不改变当前数组,按照shape创建新的数组np.resize(shape) # 改变当前数组,按照shape创建数组创建数组并且改变形状:>>>t = np.arange(24).reshape(2, 3, 4)>>>tarray([[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]],原创 2021-06-10 00:48:10 · 62 阅读 · 0 评论 -
NumPy(1)创建、属性、索引、切片
开个课题:NumPy使用# 创建a = np.array([1,2,3,4])# 创建特殊数组1. np.arange(起始数字,结束数字,步长,dtype=数据类型) # 序列数组 1. 前闭后开; 2. 起始数字省略时,默认从0开始; 3. 步长省略时,默认是12. np.ones(shape, dtype=数据类型) # 全1数组3. np.zeros(shape, dtype=数据类型) # 全0数组4. np.eye(shape) # 单位矩阵 >>>原创 2021-06-10 00:47:13 · 92 阅读 · 0 评论