Python for Data Analysis: A Beginner’s Guide

9 min read

Python for data analysis means one library doing most of the work: pandas. You load a file into a table called a DataFrame, inspect it, clean it, group it, join it to another table, and chart the result. That is the whole job, and it is roughly forty operations, all of which are written out below with their exact syntax.

You do not need to learn Python the way a software engineer learns it. No web frameworks, no object-oriented design, no game development. An analyst needs loops, conditions, functions, and then pandas.

Why Python and not something else

Python reads close to English, which is why people from non-programming backgrounds pick it up faster than most alternatives. It is free and open source, it runs on Windows, Mac and Linux, and the analysis libraries have been maintained for well over a decade. Guido van Rossum started it in 1989 and it has been the default language for data work for years now.

The practical argument is the ecosystem. Netflix uses Python for server-side analysis, Instagram is built on a Python framework, and Spotify uses it across back-end services. Indian product companies hiring analysts are running the same stack, which means the skill transfers directly.

Python also does not replace SQL or Excel. Most analyst jobs in India use all three. Python earns its place when the work becomes repetitive, when the file is too big for Excel, or when you need statistics that a spreadsheet handles badly.

The four libraries that matter

Every data analysis tutorial mentions a dozen libraries. For the first six months you need four.

Library What it does Typical use When you reach for it
pandas Holds and manipulates tabular data Loading, cleaning, filtering, grouping, joining Almost every line you write
NumPy Fast numerical arrays and maths Calculations across large numeric columns Under the hood of pandas, and directly for maths
Matplotlib Plots charts Line, bar, histogram, scatter When you need to see the shape of the data
Seaborn Statistical charts with better defaults Distributions, correlations, category comparisons When a Matplotlib chart looks ugly

Two more will come up once you move past analysis. SciPy handles statistical tests, and scikit-learn covers machine learning. Beautiful Soup is worth knowing if you plan to scrape web pages for your own datasets. None of them is where a beginner should start.

Setting up without breaking anything

Install Anaconda, which bundles Python, pandas, NumPy, Matplotlib, Seaborn and Jupyter Notebook in one download. That avoids the version conflicts that make people give up in week one.

If your laptop is old or you would rather not install anything, use Google Colab. It runs Jupyter notebooks in a browser, is free, and already has the libraries loaded. Plenty of learners in India do their entire first project in Colab on a low-spec machine.

Work in a notebook rather than a script. Notebooks run one block at a time and show the output beneath it, which is exactly how analysis actually proceeds: look at something, decide the next step, look again. If you are coming from a commerce or arts background and this already feels intimidating, it is worth reading how non-tech graduates move into analytics before you decide Python is not for you.

The DataFrame, which is the only idea you must understand

A DataFrame is a table. Rows are records, columns are fields, each column has a data type. If you have used a spreadsheet, you already have the mental model. The difference is that instead of clicking, you write an instruction, and instead of the change being invisible, it is written down and repeatable.

By convention pandas is imported as pd and NumPy as np, so almost every example you find online starts with pd. That convention is worth following from day one.

Loading data into pandas

The first table below shows how to get data in and out. The examples assume a file of orders from a Bengaluru electronics retailer, loaded into a DataFrame named orders.

Operation What it does Syntax Example
Read a CSV Loads a comma-separated file into a DataFrame pd.read_csv(path) orders = pd.read_csv(“orders.csv”)
Read an Excel file Loads one sheet from a workbook pd.read_excel(path, sheet_name) orders = pd.read_excel(“sales.xlsx”, sheet_name=”Q1″)
Read from a database Runs a SQL query and returns the result as a DataFrame pd.read_sql(query, connection) orders = pd.read_sql(“SELECT * FROM orders”, conn)
Read a JSON file Loads records from JSON pd.read_json(path) events = pd.read_json(“events.json”)
Write a CSV Saves a DataFrame back to disk df.to_csv(path, index=False) clean.to_csv(“clean_orders.csv”, index=False)

The index=False argument on to_csv stops pandas writing its row numbers into the file as an extra unnamed column. Leaving it out is the most common reason a cleaned file looks wrong when a colleague opens it in Excel.

Inspecting a dataset before you touch it

Never start analysing before you know what you have. These six checks take under a minute and catch most data problems.

Operation What it does Syntax Example
First rows Shows the top five rows df.head(n) orders.head()
Size Returns row and column counts df.shape orders.shape
Column summary Lists columns, data types and non-null counts df.info() orders.info()
Numeric summary Count, mean, min, max and quartiles per numeric column df.describe() orders.describe()
Missing values Counts blanks in every column df.isnull().sum() orders.isnull().sum()
Category counts Frequency of each value in a column df[“col”].value_counts() orders[“city”].value_counts()

Run value_counts on your city column early. It is how you discover that “Bengaluru”, “bengaluru” and “Bangalore ” are three separate values in your data and that any total you calculate is currently wrong.

Cleaning the data

Cleaning takes most of the time on a real project. Nobody advertises that, and everybody who does the job knows it.

Operation What it does Syntax Example
Drop missing rows Removes rows with blanks in a column df.dropna(subset=[“col”]) orders.dropna(subset=[“amount”])
Fill missing values Replaces blanks with a chosen value df[“col”].fillna(value) orders[“city”].fillna(“Unknown”)
Remove duplicates Deletes repeated rows by key df.drop_duplicates(subset=[“col”]) orders.drop_duplicates(subset=[“order_id”])
Change type Converts a column to another data type df[“col”].astype(type) orders[“amount”].astype(float)
Rename columns Gives columns readable names df.rename(columns={“old”: “new”}) orders.rename(columns={“amt”: “amount”})
Strip spaces Removes stray spaces from text df[“col”].str.strip() orders[“city”].str.strip()
Standardise case Puts text in one consistent case df[“col”].str.lower() orders[“city”].str.lower()
Parse dates Turns date text into real date values pd.to_datetime(df[“col”]) pd.to_datetime(orders[“order_date”])
Replace values Swaps one value for another df[“col”].replace(old, new) orders[“status”].replace(“DLVD”, “Delivered”)

Chain strip and lower together on every text column you plan to group by. It is two lines of code and it prevents the single most common reporting error in India, where the same city appears under four spellings and the revenue total splits four ways.

Selecting and filtering rows

Operation What it does Syntax Example
One column Returns a single column df[“col”] orders[“amount”]
Several columns Returns a smaller DataFrame df[[“col1”, “col2”]] orders[[“city”, “amount”]]
Filter rows Keeps only rows meeting a condition df[df[“col”] > value] orders[orders[“amount”] > 10000]
Label-based selection Selects rows and columns by name df.loc[condition, “col”] orders.loc[orders[“city”] == “Pune”, “amount”]
Position-based selection Selects rows and columns by number df.iloc[rows, cols] orders.iloc[0:10, 0:3]
Match a list Keeps rows whose value appears in a list df[df[“col”].isin(values)] orders[orders[“city”].isin([“Pune”, “Mumbai”])]
Numeric range Keeps rows inside a range df[df[“col”].between(a, b)] orders[orders[“amount”].between(500, 5000)]
Text expression Filters using a readable condition string df.query(“expression”) orders.query(“amount > 10000 and city == ‘Pune'”)

Combining conditions has one rule beginners always get wrong. Python’s own words “and” and “or” do not work on a pandas filter. You need the ampersand character for AND and the vertical bar character for OR, and every individual condition must be wrapped in its own round brackets. Forget the brackets and you get an error about ambiguous truth values, which is the most confusing message pandas produces.

Grouping, summarising and joining

This is the section that does the actual analysis. Everything above was preparation.

Operation What it does Syntax Example
Group and total Splits rows into groups and sums a column df.groupby(“col”)[“num”].sum() orders.groupby(“city”)[“amount”].sum()
Group with several summaries Applies more than one summary per group df.groupby(“col”).agg(dict) orders.groupby(“city”).agg({“amount”: [“sum”, “mean”]})
Cross-tab Builds a table like an Excel PivotTable pd.pivot_table(df, index, values, aggfunc) pd.pivot_table(orders, index=”city”, values=”amount”, aggfunc=”sum”)
Sort Orders rows by a column df.sort_values(“col”, ascending=False) orders.sort_values(“amount”, ascending=False)
Top rows Returns the highest values df.nlargest(n, “col”) orders.nlargest(10, “amount”)
Join two tables Merges on a shared key, like a SQL join pd.merge(left, right, on=”key”, how=”left”) pd.merge(orders, products, on=”product_id”, how=”left”)
Stack two tables Appends rows from one table to another pd.concat([df1, df2]) pd.concat([jan, feb])
New column Creates a calculated column df[“new”] = expression orders[“gst”] = orders[“amount”] * 0.18

The how argument on merge is worth memorising because it maps one-to-one onto SQL joins. Use “left” to keep every row from the first table, “inner” to keep only the matches, and “outer” to keep everything from both.

Charting the result

Operation What it does Syntax Example
Line chart Shows a trend over time df.plot(x, y, kind=”line”) monthly.plot(x=”month”, y=”amount”, kind=”line”)
Bar chart Compares categories df.plot(kind=”bar”) city_totals.plot(kind=”bar”)
Histogram Shows how one numeric column is distributed df[“col”].plot(kind=”hist”) orders[“amount”].plot(kind=”hist”)
Scatter plot Shows the relationship between two numbers df.plot(x, y, kind=”scatter”) orders.plot(x=”quantity”, y=”amount”, kind=”scatter”)
Statistical bar chart Draws the same comparison with better defaults sns.barplot(data=df, x, y) sns.barplot(data=orders, x=”city”, y=”amount”)
Display Renders the figure plt.show() plt.show()

Always plot a histogram of your main numeric column before reporting an average. If the distribution has a long tail, which order values in Indian retail almost always do, the mean will be misleading and you should report the median instead.

The whole workflow, end to end

Here is what a real first project looks like in order. Load the orders CSV with read_csv. Run head, shape and info to see what you have. Run isnull().sum() and decide, column by column, whether to fill the blanks or drop the rows. Strip and lower-case the text columns, then run value_counts to confirm the categories collapsed properly. Drop duplicate order IDs. Convert the order date with to_datetime and pull a month column out of it.

Then answer the question. Group by city and sum the amount to find where revenue comes from. Group by month to find the trend. Merge the products table in to see which categories drive the total. Sort, take the top ten, plot a bar chart, and write two sentences about what you found.

That sequence covers maybe thirty lines of code and it is genuinely the shape of most junior analyst work. The hard part is never the syntax. It is knowing which question is worth asking and noticing when the data is lying to you.

Python, SQL or Excel

Tool Best at Weak at Realistic role in an Indian analyst job
Excel Quick looks, small files, sharing with non-analysts Anything above a few hundred thousand rows, repeatability Daily, for fast checks and stakeholder-facing sheets
SQL Pulling and aggregating data from the company database Charts, statistics, complex reshaping Daily, and the most commonly tested skill in interviews
Python Cleaning, reshaping, statistics, automation, repeatable work Ad-hoc sharing with people who do not code Weekly to daily, growing with seniority

If you can only learn one first, learn SQL, because more listings demand it. Learn Python second, because it is what lifts you out of doing the same clean-up every month. Our breakdown of data analyst qualifications in India sets out the full sequence and what employers actually check.

Mistakes beginners make

Trying to learn all of Python. Skip web frameworks and object-oriented programming for now. Loops, conditions, functions, lists and dictionaries, then straight into pandas.

Copying code without checking the output. Run head or shape after every transformation. A filter that silently returned zero rows will not error; it will just quietly give you a wrong answer later.

Using “and” instead of the ampersand in a filter. Covered above, and it will still catch you the first three times.

Chaining operations without assigning the result. Most pandas operations return a new object rather than changing the original, so if you do not assign the result to a variable, nothing happens.

Skipping straight to machine learning. A hiring manager for an analyst role would rather see a clean, well-explained analysis of a real dataset than a model you do not understand.

Frequently asked questions

Is Python enough to become a data analyst in India?

Not on its own. Most data analyst listings in India ask for SQL and Excel alongside Python, plus a visualisation tool such as Power BI or Tableau. Python is a strong differentiator once you have those, and it is what separates an analyst who repeats work manually from one who automates it.

How long does it take to learn Python for data analysis?

For someone starting from zero and putting in one to two hours a day, basic Python takes about four weeks and working competence in pandas takes another six to eight. That gets you to the point of doing a real project unaided. Reaching interview-ready usually means three to five months, most of it spent on projects rather than tutorials.

Do I need to know maths to learn Python for data analysis?

You need school-level arithmetic and a working grasp of averages, percentages and distributions. Statistics matters more than advanced maths, and the specific parts that matter are mean versus median, standard deviation, correlation and basic hypothesis testing. You do not need calculus or linear algebra unless you move into machine learning.

What is the difference between pandas and NumPy?

NumPy provides fast numerical arrays and the maths that runs on them, with every element sharing a single data type. pandas is built on top of NumPy and adds labelled rows and columns, mixed data types, and the table operations analysts need such as grouping, joining and handling missing values. In practice you write pandas and NumPy runs underneath it.

Should I use Jupyter Notebook or a normal Python file?

Use Jupyter for analysis and a plain script for anything scheduled or automated. Notebooks let you run one block at a time and see the output immediately, which suits exploratory work. Scripts are better when the same job has to run reliably every week without a person watching it.

Can I learn Python for data analysis without a technical background?

Yes, and a large share of working analysts in India came from commerce, economics, mechanical engineering and other non-computing backgrounds. Python’s syntax is close to plain English, and analysis work rewards curiosity about a business problem more than programming ability. What it does demand is consistent daily practice for a few months.

Learn Python the way analysts actually use it

Reading about pandas is not the same as being able to open an unfamiliar CSV and produce a defensible answer from it. That comes from doing it repeatedly, with someone reviewing your work and telling you where the logic is thin.

SkilloVilla’s Data Analytics and Statistics with Python course covers Python, pandas and the statistics that make an analysis trustworthy, with live teaching, at ₹38,110. If you want it as part of a full analyst path with SQL, Excel and placement support, the Data Analytics with Python track runs 4 to 5 months of live classes at ₹71,999, currently ₹58,999.

Fees and ratings last checked August 2026; confirm current numbers with the provider before enrolling.

Data Analyst Portfolio: Projects That Get You Hired

How to build a data analyst portfolio that gets interviews: real Indian datasets you can download today, four worked project briefs, and repo guidance.
SkilloVilla Team
6 min read

Data Analyst Job Description and Career Opportunities in India

A real data analyst job description, plus the data analytics jobs in India that are actually hiring, what each one pays and how to...
SkilloVilla Team
6 min read

Data Analyst Skills Required in 2026: What Indian Employers…

The data analyst skills required in 2026, with the level of SQL, Excel, Power BI and Python Indian employers actually test at interview.
SkilloVilla Team
6 min read

Leave a Reply