我希望能够保留有关<= 25岁且<= 200磅的球员的信息。
这是我所做的:
代码1:
# importing pandas as pd
import pandas as pd
data = {'Nage':['John Doe', 'Billy Bob', 'Franky Bill'],
'Age':['27','25','27'],
'Weight':['210','185','220']}
df = pd.DataFrame(data)
df['Age']=df['Age'].astype(str).astype(float)
df['Weight']=df['Weight'].astype(str).astype(float)
# Visualize the dataframe
print(df.head())
# Print the shape of the dataframe
print(df.shape)
预期输出1:
Nage Age Weight
0 John Doe 27.0 210.0
1 Billy Bob 25.0 185.0
2 Franky Bill 27.0 220.0
(3, 3)
代码2:
# Filter all rows for which the player's
# age is less than or equal to 25 and weight less than or equ