随笔分类 -  Data Science

摘要:import pandas as pd import numpy as np help(pd.DataFrame.iterrows) Help on function iterrows in module pandas.core.frame: iterrows(self) Iterate over 阅读全文
posted @ 2021-04-27 16:23 JohnYang819 阅读(1179) 评论(0) 推荐(0) 编辑
摘要:import numpy as np from scipy import sparse (1)COO( Coordinate) 最直观的就是COO格式。它用了1维的数组来表示2维的矩阵,每个数组的长度与稀疏矩阵A的非零数字个数一样,它们的组合(i,j)组成了非零数字在稀疏矩阵中的坐标。 row,co 阅读全文
posted @ 2021-03-13 11:14 JohnYang819 阅读(193) 评论(0) 推荐(0) 编辑
摘要:np.where与pd.Series.where及pd.DataFrame用法不一样,下面一一进行学习,总结: import numpy as np import pandas as pd help(np.where) Help on built-in function where in modul 阅读全文
posted @ 2021-02-27 18:27 JohnYang819 阅读(1987) 评论(0) 推荐(0) 编辑
摘要:广播机制在numpy中居于非常重要的位置,也是numpy高效计算的秘密武器,有必要进行深入彻底的理解,简而言之,它的规则如下: 规则1:如果两个数组在维度上不一样,那么维度低的数组用1(1个或者多个)从左边开始填充。 规则2:如果维度数一样,在每个维度上的形状数不一样,那么该维度上的形状数为1的拉伸 阅读全文
posted @ 2021-01-04 23:30 JohnYang819 阅读(260) 评论(0) 推荐(0) 编辑
摘要:numpy.ndarray.transpose方法对于高维数组来讲,略微有点不太好理解。下面给出我自己对该方法的理解。 对于一个高维数组,transpose((i,j,k))可以这样理解:选取原数组的i轴上的数据作为新数组的0轴,选取原数组的j轴上的数据作为新数组的1轴。而0轴可想象为“片”,1轴可 阅读全文
posted @ 2020-12-13 09:39 JohnYang819 阅读(457) 评论(0) 推荐(0) 编辑
摘要:该库为满足特定需要的比较高效的迭代器内置库,在数据科学中的应用也不少,故有必要了解一下: import itertools import sys 无限迭代器(Infinite iterators) Iterator Arguments Results Example count() start, [ 阅读全文
posted @ 2020-10-10 13:43 JohnYang819 阅读(155) 评论(0) 推荐(0) 编辑
摘要:先说下在numpy中,个人对array的维度的比较形象的理解: array的维度就是从最外边的[]出发(可理解为array的声明),一直找到具体数值而经过的[]的数量(含最后的数值,它是最后一维) 比如: (1) [1,2]的维度是(2,),因为最外层的[]仅仅是声明,穿过该[],直接找到数值,所以 阅读全文
posted @ 2020-10-09 13:23 JohnYang819 阅读(966) 评论(0) 推荐(0) 编辑
摘要:1.创建虚拟环境 conda create -n your_virtual_env python=3.6 2.激活新创建的环境 activate your_virtual_env 3.安装nb_conda conda install nb_conda 4.如图 或者可以这样: 切换到需要的anaco 阅读全文
posted @ 2020-06-01 16:44 JohnYang819 阅读(579) 评论(0) 推荐(0) 编辑
摘要:Advanced pandas Categorical Data This section introduces the pandas type.Using it will achieve better performance and memory use in some pandas operat 阅读全文
posted @ 2020-05-24 00:33 JohnYang819 阅读(258) 评论(0) 推荐(0) 编辑
摘要:系统学习Sympy 什么是Sympy Sympy 是一个可以进行符号运算的第三方科学计算库,数学对象可以被精确的表达,而不是近似值,这也意味着带有未计算的未知量可以以符号的形式留在数学表达式中。 sqrt(3) python sympy.init_printing(use_unicode=True) 阅读全文
posted @ 2020-05-11 12:19 JohnYang819 阅读(5070) 评论(0) 推荐(1) 编辑
摘要:在pandas中,两个DataFrame的差集并没有直接的库内置方法,现在我们希望有一种方法,就像python中set内置的求差集一样,来找到两个DataFrame的差集。 >>> a=set((1,2,3)) >>> a {1, 2, 3} >>> b=set((2,3,4)) >>> b {2, 阅读全文
posted @ 2020-05-08 11:12 JohnYang819 阅读(12144) 评论(0) 推荐(0) 编辑
摘要:Time Series Date and Time data types and tools datetime.datetime(2020, 5, 5, 9, 51, 27, 686891) (2020, 5, 5) datetime.time(9, 51, 27, 686891) stores b 阅读全文
posted @ 2020-05-05 13:23 JohnYang819 阅读(424) 评论(0) 推荐(0) 编辑
摘要:Data aggregation and group operations in pandas After loading,merging and preparing a dataset,you may need to compute group statistics or possibly piv 阅读全文
posted @ 2020-04-28 13:21 JohnYang819 阅读(1205) 评论(0) 推荐(0) 编辑
摘要:Plotting and visualization through matplotlib and pandas A brief matplotlib API primer [] Figures and subplots Plots in matplotlib reside within a obj 阅读全文
posted @ 2020-04-23 00:12 JohnYang819 阅读(621) 评论(0) 推荐(0) 编辑
摘要:pandas.read_csv() 报错 OSError: Initializing from file failed,一般由两种情况引起:一种是函数参数为路径而非文件名称,另一种是函数参数带有中文。 对于第一种情况很简单,原因就是没有把文件名称放到路径的后面,把文件名称添加到路径后面就可以了。还可 阅读全文
posted @ 2020-04-22 11:56 JohnYang819 阅读(276) 评论(0) 推荐(0) 编辑
摘要:Data wrangling:Join,Combine,and Reshape,in Pandas Hierarchical indexing a 1 0.396969 2 0.348014 3 1.340860 b 1 0.502245 3 0.640700 c 1 0.063639 2 1.29 阅读全文
posted @ 2020-04-19 23:32 JohnYang819 阅读(532) 评论(0) 推荐(0) 编辑
摘要:String Manipulation related with pandas String object Methods ['a', 'b', ' guido'] ['a', 'b', 'guido'] 'a::b::guido' 2 1 'a:b: guido' 'A,B, GUIDO' 'od 阅读全文
posted @ 2020-04-16 20:21 JohnYang819 阅读(150) 评论(0) 推荐(0) 编辑
摘要:Data Preparation in Pandas Data cleaning 0 aardvark 1 artichoke 2 NaN 3 avocado dtype: object 0 False 1 False 2 True 3 False dtype: bool nan 0 1.0 2 3 阅读全文
posted @ 2020-04-16 13:32 JohnYang819 阅读(193) 评论(0) 推荐(0) 编辑
摘要:Axis in DataFrame Optional parameter axis may appear in arithmetric between DataFrame and Series,the key point understanding the meaning of axis is ma 阅读全文
posted @ 2020-04-02 21:47 JohnYang819 阅读(177) 评论(0) 推荐(0) 编辑
摘要:Summary of Indexing operation in DataFrame of Pandas For new users of pandas, the index of DataFrame may seem confusing, so personally I list all its 阅读全文
posted @ 2020-04-02 00:42 JohnYang819 阅读(183) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示