标签:alt res img numpy load print bsp 对象 style
Series是一种类似于一维数组的对象,它由一组数据(各种numpy数据类型)以及一组与之相关的数据标签(索引)组成。
也可以看成一个定长的有序字典。
如果未指定索引,索引默认为0只n-1
import pandas as pd obj_1 = pd.Series([‘1‘, ‘2‘, ‘3‘]) obj_2 = pd.Series((‘1‘, ‘2‘, ‘3‘)) print(‘obj_1‘, obj_1) print(‘obj_2‘, obj_2)
import pandas as pd obj_1 = pd.Series([‘1‘, ‘2‘, ‘3‘], index=[‘a‘, ‘b‘, ‘c‘]) obj_2 = pd.Series((‘1‘, ‘2‘, ‘3‘), index=[‘a‘, ‘b‘, ‘c‘]) dict_1 = {‘a‘:1, ‘b‘:‘2‘, ‘c‘:‘3‘} obj_3 = pd.Series(dict_1) print(‘obj_1‘, obj_1) print(‘obj_2‘, obj_2) print(‘obj_3‘, obj_3)
import pandas as pd series_1 = pd.Series([1, 2, 3], index=[‘a‘, ‘b‘, ‘c‘]) result_1 = series_1[‘a‘] result_2 = series_1[[‘b‘, ‘c‘]] result_3 = ‘c‘ in series_1 result_4 = ‘d‘ in series_1 result_5 = series_1[series_1 > 2] # 布尔类型 print(‘result_1‘, result_1) print(‘result_2‘, result_2) print(‘result_3‘, result_3) print(‘result_4‘, result_4) print(‘result_5‘, result_5)
import pandas as pd series_1 = pd.Series([1, 2, 3], index=[‘a‘, ‘b‘, ‘c‘]) series_2 = pd.Series([4, 5, 6], index=[‘b‘, ‘c‘, ‘d‘]) result_1 = series_1 + series_2 result_2 = series_1 - 2 result_3 = series_1 * 2 print(‘result_1‘, result_1) print(‘result_2‘, result_2) print(‘result_3‘, result_3)
Series对象本身及其索引都有?个name属性,该属性跟pandas
其他的关键功能关系?常密切
标签:alt res img numpy load print bsp 对象 style
原文地址:https://www.cnblogs.com/qianslup/p/11891449.html