# 6.1 Columns आणि rows select करूया

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

आधी हा sample DataFrame तयार करा. पुढच्या lessons मधले filters ह्याच data वर वापरणार आहोत.

import pandas as pd

df = pd.DataFrame({
    "order_id": [
        "BLK-260314-001", "BLK-260314-002", "BLK-260314-003",
        "AMN-260314-004", "BLK-260314-005", "AMN-260314-006",
        "BLK-260314-007", "BLK-260314-008",
    ],
    "city": [
        "Pune", "Nashik", "Nagpur", "Kolhapur",
        "Solapur", "Sambhaji Nagar", "Pune", "Pune",
    ],
    "amount": [64, 90, 240, 58, 1299, 195, 60, 110],
    "status": [
        "Delivered", "Delivered", "Delivered", "Cancelled",
        "Delivered", "Delivered", "Delivered", "Returned",
    ],
    "customer": [
        "Ruhi Bagale", "Amir", "Salman", "Zoya",
        "Raja", "Rani", "Shahrukh", "Ravina",
    ],
    "delivery_mins": [9, 12, 11, 14, 18, 10, 8, 13],
})

df["city"]                    # Series
df[["city", "amount"]]        # DataFrame — note double brackets
df.loc[0:2, ["city", "amount"]]
df.iloc[0:3, 0:3]             # position-based

df["city"] एक Series देते. अनेक columns साठी आत list द्यावी लागते. loc labels वर काम करतो, तर iloc positions वर.

इथल्या loc[0:2] मध्ये label 2 समाविष्ट होतो. iloc[0:3] मध्ये शेवटची position 3 समाविष्ट होत नाही; 0, 1, 2 या positions मिळतात.

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

df["city", "amount"] लिहिलं तर KeyError येऊ शकतो. अनेक columns हवे असतील तर df[["city", "amount"]] असे double brackets वापरा.
