Python for Data Science

    Yash Kabra3 min readUpdated

    Python is the most popular language for data science because it is easy to read and has a rich ecosystem of libraries built specifically for working with data. The two you will use most are NumPy for fast numerical arrays and pandas for tables of data. Together they let you load, clean, analyse, and summarise data in just a few lines.

    Why Python?

    • Readable syntax that reads almost like English, so beginners get productive fast.
    • A huge library ecosystem — NumPy, pandas, Matplotlib, scikit-learn, and more.
    • A large community, which means answers to almost any question are a search away.
    • It is free and open source, running on any operating system.

    The core libraries

    LibraryWhat it does
    NumPyFast arrays and numerical maths
    pandasTables (DataFrames) for real-world data
    MatplotlibPlotting and charts
    scikit-learnMachine-learning models

    Most data work starts with NumPy and pandas. The current versions are pandas 2.x and NumPy 2.x, which is what the examples below assume.

    NumPy: fast number crunching

    NumPy gives you the array, a container that does maths on whole sequences at once:

    import numpy as np  # NumPy 2.x — the standard import alias is np
    
    temps = np.array([28.5, 31.2, 29.8, 33.1, 30.0])
    
    # Whole-array maths, no loops needed
    print("Mean:", temps.mean())
    print("Hottest:", temps.max())
    
    # Element-wise operations apply to every value at once
    fahrenheit = temps * 9 / 5 + 32
    print(fahrenheit)
    

    pandas: working with tables

    pandas builds on NumPy to give you the DataFrame — a spreadsheet-like table you can filter, group, and summarise:

    import pandas as pd  # pandas 2.x
    
    students = pd.DataFrame({
        "name": ["Aarav", "Diya", "Kabir"],
        "city": ["Jalgaon", "Pune", "Jalgaon"],
        "marks": [78, 92, 65],
    })
    
    # Filter rows: students from Jalgaon
    jalgaon = students[students["city"] == "Jalgaon"]
    print(jalgaon)
    

    Want to learn this properly?

    Join the waitlist for our courses — beginner-friendly, project-first classes in Jalgaon.

    Browse courses

    Group and aggregate: average marks per city

    print(students.groupby("city")["marks"].mean())

    
    If you want to go deeper into tables, see our [pandas for analytics](/learn/data-science-analytics/pandas-for-analytics) guide.
    
    ## A complete mini-analysis
    
    ```python
    import pandas as pd
    
    # Load a CSV file into a DataFrame (the most common starting point)
    df = pd.read_csv("sales.csv")
    
    # Quick health check: shape, column types, first rows
    print(df.shape)          # (rows, columns)
    print(df.dtypes)         # data type of each column
    print(df.head())         # first five rows
    
    # A simple insight: total sales per product
    print(df.groupby("product")["amount"].sum().sort_values(ascending=False))
    

    That short script — load, inspect, summarise — is the backbone of countless real analyses.

    Common mistakes

    • Using df.append(). This method was removed from modern pandas. Use pd.concat([df1, df2], ignore_index=True) to combine DataFrames instead.
    • Reaching for .ix. This indexer was removed long ago. Use .loc (label-based) or .iloc (position-based).
    • Writing Python loops over rows. Vectorised pandas/NumPy operations are far faster and cleaner.
    • Not checking data types. Numbers read as text will break your maths — check df.dtypes early.

    FAQ

    Do I need to know Python before data science? Just the basics — variables, lists, functions, loops. You learn the data-specific parts as you go.

    Python or R? Both are excellent. Python is more general-purpose and has a larger ecosystem, which is why we recommend it for beginners.

    Which version? Use a current Python 3 release with pandas 2.x and NumPy 2.x.

    Keep learning

    Python is your gateway into everything else in data science. Next, build on it with statistics basics and data cleaning, or browse the full Data Science & Analytics hub.

    Want to learn Python for data with guided projects? Join the waitlist for the Data Science & Analytics course at Infoplanet, Jalgaon.

    Want to learn this properly?

    Join the waitlist for our courses — beginner-friendly, project-first classes in Jalgaon.

    Browse courses
    Yash Kabra

    Founder, Atlee Technologies

    Yash Kabra is the founder of Atlee Technologies, a product studio that ships SaaS products end-to-end. He owns products from strategy through launch and growth — including Infoplanet, TrackRise and Perqee — and teaches AI, Machine Learning and Data Science at Infoplanet with a focus on how these tools are used to build real products.

    Related guides