Big data's Analysis of practical Learning Notes based on python-DataFrame of pandas
Then in the previous article, we went on to DataFrame in pandas. Without saying much, we went straight to the code with comments.
# the operation of dataframe is nothing more than adding, deleting, changing and checking
From pandas import Series
From pandas import DataFrame
Df=DataFrame ({'age':Series ([18d20 ~ 30]))
'name':Series ([' x1pm / x2pm / / x3'])
})
Print (df)
''
Access column: variable name [column name]
Access line: variable name [nRom] access line n to line mmur1
Access blocks (rows and columns): variable names .iloc [n1:n2, m1:m2] access data from N1 to N2-1 rows and M1 to m2-1 columns
Access the specified location: variable name .at [row index, column name]
''
# access column
A=df ['age']
Print (a)
# access lines
B=df [1:3]
Print (b)
# access block
C=df.iloc [0:4,0:2]
Print (c)
# access the specified location
D=df.at [0reachingname']
Print (d)
# add columns
Df ['address'] = [' Earth', 'moon', 'Mars']
Print (df)
# Delete columns
# del df ['address']
# add lines
Df.loclen (df)] = [40, 'x4mom,' Jupiter']
Print (df)
# Delete rows, according to row index
# df.drop (1)
Isn't it easy? As long as you have the foundation of python, you can do it in minutes.