🐍 Python
Advanced
What is Pandas in Python?
Answer
Pandas is Python's primary data manipulation library, built on NumPy. It provides two main data structures: Series (1D labeled array) and DataFrame (2D labeled table — like a spreadsheet or SQL table). Load CSV: df = pd.read_csv("data.csv"). Inspect: df.head(), df.info(), df.describe(). Select: df["col"] (Series), df[["col1", "col2"]] (DataFrame), df.loc[row, col] (label-based), df.iloc[0, 1] (position-based). Filter: df[df["age"] > 25]. Group: df.groupby("city")["salary"].mean(). Merge: pd.merge(df1, df2, on="id"). Handle missing: df.dropna(), df.fillna(0). Apply functions: df["name"].apply(str.upper). Pandas is indispensable for data cleaning, exploration, and transformation in data science workflows.