Pandas library 01_Series data types

#pandas There are two basic data structures, Series and DataFrame, these two data types are indexed
# simple to say, Series is an indexed data, DataFrame is the same as the form of indexed data structure

import pandas as pd

Series # Create data, two ways, one assignment index system, two kinds of creating their own index
# objs1 pd.Series = ([l, 2,3, -2,2,8,2])
# Print (objs1) # this is the data with the index value starting from 0, the image dictionary and the dictionary is not
# Print (type (objs1)) # <class 'pandas.core.series.Series'>
#
# objs2 pd.Series = ([. 1 , 2,3,4,1,5,3], index = [ "A", "B", "C", "D", "E", "F", "G"])
# Print (objs2 )

Data access #
# objs3 = pd.Series ([1,2,3,4,1,5,3] , index = [ "a", "b", "c", "d", "e", " F "," G "])
# Print (objs3.index) #Index ([ 'A', 'B', 'C', 'D', 'E', 'F', 'G'], DTYPE = 'Object')
# Print (objs3.values) # [2. 3. 1. 5. 4. 3. 1]
after # print (objs3 [ "c" ]) # specify the index, the index is still in the system, it can be used objs3 [0] and so access value
#
# = objs4 pd.Series ([l, 2,3, -2,2,8,2]) The system specified index #
# print (objs4.index) #RangeIndex (start = 0, stop = 7, step = 1 )
# Print (List (objs4.index)) # [0,. 1, 2,. 3,. 4,. 5,. 6]
# Print (objs4.values) # [. 1. 3 -2 2 2 2. 8]
# Print (objs4 [ . 4])
# Print (objs4 [objs4 <. 3]) # screening conditions can also be obtained objs new index value without changing the original data
# print (objs4)

# You can also create a dictionary
# objs5 = pd.Series ({ "tanghao ": " Don Ho", "xiaofeng": "small wind", "laowang": "Pharaoh"})
# Print (objs5)
# Print ( "________________")
# # define name attribute
# objs5.name = "student table"
# Print (objs5)
# Print ( "________________")
# objs5.index.name = "students"
# Print (objs5)
# Print ( " ________________ ")
# # objs5.value.name =" Chinese name "# wrong, do not have this, can only be defined index.name

Guess you like

Origin www.cnblogs.com/yiyea/p/11441787.html