I want to load only users who their status are "Disabled" in Status column into Pandas data frame. My initial code is like this
import pandas as pd
df = pd.read_excel('Users.XLSX', sheet_name='WebUsers', usecols="A,B")
print(df)
Which is bringing all users no matter they are "Disabled" or "Active". Can you please let me know how to add a filter like WHERE 'Status' == 'Disabled' and load only disabled users into frame?
>Solution :
You can’t do that with Pandas, you have to filter after Pandas loads the file:
df = (pd.read_excel('Users.XLSX', sheet_name='WebUsers', usecols=['A', 'B', 'Status'])
.query("Status == 'disabled'").drop(columns='Status'))
Note: parquet is a column-oriented data file format so you can filter your dataframe before.