1、 obtain DataFrame The number of rows and columns of
# Get the number of lines
df.shape[0]
len(df)
# Get the number of columns
df.shape[1]
example:
import pandas as pd
df = pd.DataFrame({'1':[0.4,2.6],'2':[1.4,0.2],'3':[1.8,2.2]})
print(df)
print('row=',df.shape[0],',','col=',df.shape[1])
print('row=',len(df))
result:
2、 obtain DataFrame Some element of
df.iat[row,col]
example:
import pandas as pd
df = pd.DataFrame({'1':[0.4,2.6],'2':[1.4,0.2],'3':[1.8,2.2]})
print(df.iat[1,2])
result:2.2