# 6.2 Boolean filters

Source: https://ravindrabagale.com/mr/datascience/ch06-selecting-filtering-and-sorting/6-2-boolean-filters.html
Language: mr (Marathi with English technical terms)

अट प्रत्येक row साठी True किंवा False देते. True असलेल्या rows filter मधून पुढे येतात:

pune = df[df["city"] == "Pune"]
delivered = df[df["status"] == "Delivered"]
big = df[df["amount"] >= 200]

अटी जोडण्यासाठी & | ~ वापरा. प्रत्येक अट वेगळ्या parentheses मध्ये ठेवा:

mask = (df["city"] == "Pune") & (df["status"] == "Delivered")
pune_ok = df[mask]
print(pune_ok)

# Cancelled or Returned
bad = df[df["status"].isin(["Cancelled", "Returned"])]
# Not Pune
not_pune = df[~(df["city"] == "Pune")]

Jupyter मध्ये करून पाहा

मागच्या lesson मधला df तयार करा.

Nashik किंवा Nagpur मधल्या Delivered rows:
df[(df["status"]=="Delivered") & (df["city"].isin(["Nashik","Nagpur"]))]

₹100 ते ₹500 amount साठी:
df[df["amount"].between(100, 500)]

प्रत्येक filter नंतर .shape तपासा.

Pune Delivered मध्ये Ruhi आणि Shahrukh च्या rows दिसतील. “big” filter मध्ये Solapur ची ₹1,299 row दिसेल.

रवींद्र बागले यांची tip

pandas च्या Series conditions साठी and/or ऐवजी & आणि | वापरा; parentheses विसरू नका.
