Assessing rows from dataFrame with boolean indexes (True / False)
import pandas as pd
# Create a sample DataFrame
data = {
"Student": ["Alice", "Bob", "Charlie", "David"],
"Math": [85, 90, 78, 88],
"English": [92, 80, 85, 90],
"Science": [88, 79, 93, 85]
}
df = pd.DataFrame(data,index=[True,False,True,False])
df=df.loc[True]
print(df)
Assessing rows from dataFrame with boolena indexes (0/1)
import pandas as pd
# Create a sample DataFrame
data = {
"Student": ["Alice", "Bob", "Charlie", "David"],
"Math": [85, 90, 78, 88],
"English": [92, 80, 85, 90],
"Science": [88, 79, 93, 85]
}
df = pd.DataFrame(data,index=[0,1,0,1])
df=df.loc[1]
print(df)
Assessing rows from dataFrame with boolena indexes
import pandas as pd
# Create a sample DataFrame
data = {
"Student": ["Alice", "Bob", "Charlie", "David"],
"Math": [85, 90, 78, 88],
"English": [92, 80, 85, 90],
"Science": [88, 79, 93, 85]
}
df = pd.DataFrame(data,index=[True,False,True,False])
df=df.loc[df["Math"]>85]
print(df)
0 Comments
Please do note create link post in comment section