Run
import pandas as pd # Take a DataFrame df = pd.DataFrame({ 'name': ['apple', 'banana', 'cherry', 'fig', 'mango', 'pear'], 'quantity': [14, 0, 0, 37, 25, 80] }) # Select rows whose index is even df_even_rows = df.iloc[::2] # Print DataFrame print(f"Original DataFrame\n{df}\n") print(f"Rows at even index\n{df_even_rows}")
Output