Filter Pandas DataFrame Based on Index
To filter Pandas DataFrame based on the index: Copy df_filter = df.filter(items=[index to keep], axis=0) Example Suppose that you created the DataFrame below: Copy import pandas as pddata = { “Product”: [“Computer”, “Printer”, “Monitor”, “Desk”, “Phone”, “Tablet”, “Scanner”], “Price”: [900, 200, 300, 450, 150, 250, 150],}df = pd.DataFrame(data)print(df) As you can see in yellow, the … Read more