---restore content starts---
D Definition:
Pandas is a powerful toolkit for data analysis in Python.
Pandas is built on the basis of numpy.
Installation method:pip Install pandasimport pandas as PDMain functions of Pandas
A data structure with its functions dataframe, Series
Integrated time series capabilities
Provides a wealth of mathematical operations and operations
Flexible handling of missing data
Series
Definition: A series is an object that resembles a single array, consisting of a set of data and a set of data labels (indexes) associated with it.
How to create:
How to create: PD. Series ([4,7,-5,3]) PD. Series ([4,7,-5,3],index=['a','b','C','D']) PD. Series ({'a':1,'b':2}) PD. Series (0, index=['a','b','C','d '])
Get an array of values and an indexed array: Value property and Index property
Series comparison is a combination of a list (array) and a dictionary.
Instance:
SR=PD. Series ([1,2,3,4],index=['a','b','C','D']) sr['a':'C']==>a-4b3C5dtype:int64sr[['a','D']]==a-4D6Dtype:int64 The condition is that the key is not a value'b' inchSR==true1 inchSR==Flase: The method to take the value is similar to the dictionary Sr.Get('a',0)
Judging, slicing, taking value
SR=PD. Series ([1,2,3,4],index=['b','C','D','a']) b1C2D3a4dtype:int64sr.iloc[1] #取索引为1==2sr.ilc[2] #取索引为2==3
Fetch Index
SR=PD. Series ([1,2,3,4],index=['b','C','D','a']) SR1=PD. Series ([5,6,7,8,9],index=['a','b','C','D','e']) SR2=PD. Series ([5,6,7,8,9,Ten],index=['a','b','C','D','e','F']) SR+SR1==a9.0b7.0C9.0D11.0e nandtype:float64ps: The extra value is just the Nanadd method SR3=sr.add (sr2,fill_value=0) SR3:==a9.0b7.0C9.0D11.0e9.0F10.0Dtype:float64 with the Add method: No, the Nan is not present
Add method and A+b difference
sr4a9.0b7.0C9.0D11.0e NaNdtype:float64sr4.notnull () a trueb truec trued truee falsedtype:BOOLsr4[sr4.notnull ()] #把是NAN的去掉a9.0b7.0C9.0D11.0Sr4.dropna () #也是直接去掉为nan的a9.0b7.0C9.0D11.0Dtype:float64
Notnull () and Dropna ()
SR=PD. DataFrame ({' One':[1,2,3,4],' Both':[ +,4,5,6]},index=['a','s','D','Q'])
= [Random.uniform (ten, 6.3 list (map (lambda x:x*ratio, Li))
Map Function Call
DF = pd.read_csv ('601318.csv', Header=none, names=list ('asdfghjk') ))
DF = pd.read_csv ('601318.csv', index_col=1, parse_dates=['date ']) DF
Df.groupby ('key1'). SUM ()
---restore content ends---
Algorithm-LOWB three-person group