1.Series概念 类似一维数组的对象,由数据和索引组成 2.Series创建 用Series()函数创建,0,1,2为series结构自带的索引. 可以自己指定索引值,用index,也可以直接用字典 3.Series的基本运算 ①所有的索引和值查询:index和value ②查找某个值的索引:bSer['a']   >>3 ③*2:  bSer*2    >>>1     2 2     4 3     aa 4.Series的数据对齐 ①检测值为空:isnull函数 ②…
Series的基本特征: 1.类似一维数组的对象 2.由数据和索引组成 import pandas as pd >>> aSer=pd.Series([1,2.0,'a']) >>> aSer 0 1 1 2 2 a dtype: object bSer=pd.Series(['apple','peach','lemon'],index=[1,2,3]) >>> bSer 1 apple 2 peach 3 lemon dtype: object &g…
<OOC>笔记(3)——C语言变长参数va_list的用法 C语言中赫赫有名的printf函数,能够接受的参数数目不固定,这就是变长参数.C#里也有params这个关键字用来实现变长参数. printf("Hello Mozart!"); printf("Hello %s!", "Mozart"); printf(, "Mozart"); 用C实现一个能接受变长参数的函数 举例如下. #include <st…
最近开发遇到一个功能需求,目的是要获取一个AI分析结果中最长连续帧,比如一个视频中连续3帧有人,那么我认为这个视频就是有人,我就要判断这个视频帧列表中是否有连续的三帧有人.本质就是获取列表中的最长连续数字,比如有一个列表 a = [1,2,3,4,1,2,3],要获取这个列表中最长连续数字,应该是[1,2,3,4]. 拓展,比如我想获取每隔n的最长连续数字怎么办?例如:b = [1,3,5,7,9,1,4,7,10],我想获取每隔2的最长连续数字,应该是[1,3,5,7,9],我想获取每隔3的最…
一.列表生成式 列表生成式就是python设置的可以用来可以生成列表的. 如要生成一个0-9的列表我们可以通过以下代码实现: >>> list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 但是如果生成的列表较为复杂呢?例如生成包含0².1².2²...9²这样一个列表: >>> L = [] >>> for i in range(10): ... L.append(i*i) ... >>> L…
python自定义函数中有两种不定长参数, 第一种是*name:加了星号 * 的参数会以元组(tuple)的形式导入 第二种是**name:加了星号 * *的参数会以字典(dict)的形式导入 *name形式: def add(a, b, *args): print(a) print(b) print(args) add(, , , , , )---------------------------12(3,4,5,6) **name形式: def aaa(a, b, **kwargs): pri…
10 Minutes to pandas 引 By “group by” we are referring to a process involving one or more of the following steps Splitting the data into groups based on some criteria Applying a function to each group independently Combining the results into a data st…
10 Minutes to pandas Concat df = pd.DataFrame(np.random.randn(10, 4)) print(df) # break it into pieces pieces = [df[:3], df[3:7], df[7:]] print(pd.concat(pieces)) # 0 1 2 3 # 0 0.879526 -1.417311 -1.309299 0.287933 # 1 -1.194092 1.237536 -0.375177 -0…
10 Minutes to pandas #Stats # shift 这玩意儿有啥用??? s = pd.Series([1,5,np.nan], index=dates).shift(0) # s1 = pd.Series([1,5,np.nan], index=dates).shift(1) # s2 = pd.Series([1,5,np.nan], index=dates).shift(2) # print(s) # print(s1) # print(s2) # 2018-01-16…
10 Minutes to pandas import pandas as pd import numpy as np import matplotlib.pyplot as plt dates = pd.date_range(', periods=3) # 创建 16 17 18 等六个日期 df = pd.DataFrame(np.random.randn(3,4), index=dates, columns=list('ABCD')) # 这是二维的,类似于一个 df1 = df.rein…