How to Use Python Instead of Excel: A Beginner’s Guide (2026)

If you have ever spent hours clicking through Excel menus trying to sort data, create charts, or remove duplicates, Python might be the upgrade you need. In this guide, you will learn how Python with the pandas library can replace Excel for everyday data tasks — and do it faster once you know the basics.

Why Consider Python Over Excel?

Excel is great for quick, small-scale tasks. But once your spreadsheet grows past a few thousand rows, things slow down. Formulas break. Files crash. Python handles millions of rows without breaking a sweat.

Here is what Python offers over Excel:

  • Reproducible workflows you can run again with one command
  • No row limits (Excel caps at about 1 million rows)
  • Automation of repetitive tasks
  • Free and open-source tools

Setting Up Python and Pandas

Before you start, you need Python 3.12 or later installed on your computer. Then install pandas using pip.

# Install pandas from your terminal
# pip install pandas openpyxl matplotlib

Once installed, you can import pandas in any Python script:

import pandas as pd

print(pd.__version__)

Output:

2.2.0

Reading Data from Excel or CSV

In Excel, you open a file by double-clicking it. In Python, you use one line of code.

import pandas as pd

# Reading a CSV file
df = pd.read_csv("sales_data.csv")

# Reading an Excel file
# df = pd.read_excel("sales_data.xlsx")

# View first 5 rows
print(df.head())

Output:

   Product  Units_Sold  Revenue  Month
0   Widget         120     2400  Jan
1   Gadget          85     4250  Jan
2   Widget         140     2800  Feb
3   Gadget          90     4500  Feb
4   Widget         110     2200  Mar

Sorting Data

In Excel, you go to Data > Sort. In Python, it takes one line.

# Sort by Revenue in descending order
sorted_df = df.sort_values("Revenue", ascending=False)
print(sorted_df.head())

Output:

   Product  Units_Sold  Revenue  Month
3   Gadget          90     4500  Feb
1   Gadget          85     4250  Jan
2   Widget         140     2800  Feb
0   Widget         120     2400  Jan
4   Widget         110     2200  Mar

Filtering Rows

In Excel, you use filters or complex IF formulas. In Python, you write conditions directly.

# Filter rows where Revenue is above 3000
high_revenue = df[df["Revenue"] > 3000]
print(high_revenue)

Output:

   Product  Units_Sold  Revenue  Month
1   Gadget          85     4250  Jan
3   Gadget          90     4500  Feb

You can combine multiple conditions too:

# Filter: Gadget products sold more than 85 units
result = df[(df["Product"] == "Gadget") & (df["Units_Sold"] > 85)]
print(result)

Output:

   Product  Units_Sold  Revenue  Month
3   Gadget          90     4500  Feb

Removing Duplicates

In Excel, you navigate to Data > Remove Duplicates. In Python:

# Remove duplicate rows
clean_df = df.drop_duplicates()
print(f"Rows before: {len(df)}, Rows after: {len(clean_df)}")

Output:

Rows before: 5, Rows after: 5

Creating Formulas and Calculated Columns

Excel formulas like =B2*C2 become simple column operations in Python.

# Add a new column: Price per Unit
df["Price_Per_Unit"] = df["Revenue"] / df["Units_Sold"]
print(df[["Product", "Revenue", "Units_Sold", "Price_Per_Unit"]])

Output:

   Product  Revenue  Units_Sold  Price_Per_Unit
0   Widget     2400         120       20.000000
1   Gadget     4250          85       50.000000
2   Widget     2800         140       20.000000
3   Gadget     4500          90       50.000000
4   Widget     2200         110       20.000000

Creating Charts

Excel charts require clicking through menus. Python creates them with a few lines using matplotlib.

import matplotlib.pyplot as plt

# Group by Product and sum Revenue
product_revenue = df.groupby("Product")["Revenue"].sum()

# Create a bar chart
product_revenue.plot(kind="bar", color=["#3498db", "#e74c3c"])
plt.title("Total Revenue by Product")
plt.xlabel("Product")
plt.ylabel("Revenue ($)")
plt.tight_layout()
plt.savefig("revenue_chart.png")
print("Chart saved as revenue_chart.png")

Output:

Chart saved as revenue_chart.png

Saving Your Results

Just like “Save As” in Excel, you can export to CSV or Excel format.

# Save to CSV
df.to_csv("processed_data.csv", index=False)

# Save to Excel
df.to_excel("processed_data.xlsx", index=False)
print("Files saved successfully.")

Output:

Files saved successfully.

When to Stick with Excel

Python is not always the better choice. Use Excel when:

  • You need a quick one-time look at a small dataset
  • You are sharing files with people who only know Excel
  • You need collaborative editing in real time (Google Sheets)

Use Python when:

  • Your data exceeds a few thousand rows
  • You repeat the same analysis weekly or monthly
  • You need to combine data from multiple sources
  • You want reproducible, documented workflows

FAQ

Is Python harder to learn than Excel?

Python has a steeper initial learning curve, but once you know the basics, many tasks become faster and easier than in Excel. Most beginners can start doing useful things with pandas within a few days of practice.

Do I need to uninstall Excel to use Python?

No. Many professionals use both. You can read Excel files directly in Python and save results back to Excel format. They complement each other.

What is pandas in Python?

Pandas is a free, open-source Python library designed for data manipulation and analysis. It provides data structures like DataFrames that work similarly to Excel spreadsheets but with far more power and no row limits.

Can Python replace Excel at work?

For data analysis, reporting, and automation tasks, yes. For collaborative real-time editing or very quick one-off tasks, Excel or Google Sheets may still be more practical.

How long does it take to learn pandas?

If you already know basic Python, you can learn enough pandas to replace common Excel tasks in about one to two weeks of regular practice.

Leave a Comment

Scroll to Top