Python Basics for Accountants: Learn Pandas, Excel Automation & Financial Analysis

Python is becoming a must-have skill for finance professionals. This guide teaches accountants how to use Python and the pandas library to automate GST reconciliation, bank reconciliation, aging reports, and month-end close tasks — with real code snippets, a 30-day learning plan, and salary data for Python-skilled accountants in India.

Why Python for Accountants

Ten years ago, the most sought-after technical skill for finance professionals was advanced Excel. Today, it is Python. The reason is straightforward: accounting work is increasingly data-intensive, and Excel has practical limits — on row count, on automation, on connecting to external data sources, and on handling the kind of large-scale data analysis that modern business requires.

Python is not replacing accountants. It is replacing the most tedious parts of what accountants do: manually matching thousands of GST invoices, reconciling bank transactions line by line, generating aging reports from raw data, and reformatting trial balances every month-end. These are tasks that take 4-8 hours in Excel and 20-30 minutes in Python once the script is written.

The Salary Premium Is Real

Based on Naukri.com and LinkedIn job postings analyzed in 2024, finance professionals in India with demonstrated Python skills earn a salary premium of ₹4-8 LPA over comparable candidates without the skill. At the mid-level (5-8 years experience), this gap is even wider. Job titles specifically requiring Python in finance include FP&A Analyst, Data Finance Analyst, Finance Automation Specialist, and Business Finance Manager at tech and BFSI companies.

Industry Context

Big 4 firms use Python internally for data analytics in audit and advisory. Startups and fintech companies expect their finance teams to work with data pipelines. Shared service centers of MNCs (Infosys BPO, Accenture, Genpact, WNS) explicitly list Python in JDs for Finance Analyst roles. For CA, CPA, CMA, or ACCA professionals targeting these roles, Python is no longer optional — it is a differentiator.

Python vs Excel: When to Use Which

Criteria Excel Python
Max practical rows~1 million (slow above 100K)100M+ rows with chunking
Learning curveLow — already knownMedium — 30-60 days for basics
Automation / schedulingLimited (VBA, Power Automate)Excellent — can schedule scripts
ReusabilityLow — manual re-run each timeHigh — run same script on new data
Data source connectivityLimited (Power Query helps)Connects to SQL, APIs, PDFs, web
Presentation / chartingExcellent — ready for stakeholdersGood (matplotlib) — needs formatting
Formula complexityGets unwieldy in large modelsCode is more readable at scale
Audit trailDifficult — cells can changeScripts are version-controllable
Best forInteractive analysis, presentations, small datasetsAutomation, large data, repeatable processes

The right answer for most accountants is both: use Python to process and transform data, then output a formatted Excel file for presentation and sharing with stakeholders.

Setting Up Python (No Installation Complexity)

The easiest way to start Python for accounting is with Anaconda — a free distribution that includes Python, Jupyter Notebook, and all the finance libraries pre-installed.

Step-by-Step Setup

  1. Download Anaconda: Go to anaconda.com/download, choose the Windows/Mac installer for Python 3.x, download and install (takes 5-10 minutes).
  2. Open Jupyter Notebook: After installation, open "Anaconda Navigator" from your start menu, then click "Launch" under Jupyter Notebook. This opens a browser-based interface.
  3. Create a new notebook: Click "New" → "Python 3". This is your coding environment — you type Python code in cells and press Shift+Enter to run each cell.
  4. Test the setup: In the first cell, type import pandas as pd and press Shift+Enter. If there is no error, your setup is complete.

Alternatively, use Google Colab (colab.research.google.com) — a free browser-based Python environment with no installation required. Ideal for learning and experimenting without touching your work computer setup.

Python Basics for Non-Programmers

You do not need to learn all of Python. Accountants need five concepts: variables, lists, dictionaries, loops, and functions. Everything else follows from these.

Variables

# Variables store data — no need to declare type revenue = 4500000 # integer margin_pct = 0.124 # float (decimal) company = "TechCorp Ltd" # string (text) is_listed = True # boolean # Basic arithmetic gross_profit = revenue * margin_pct print(f"Gross Profit: ₹{gross_profit:,.0f}") # Output: Gross Profit: ₹558,000

Lists and Dictionaries

# List: ordered collection of items months = ["Apr", "May", "Jun", "Jul", "Aug", "Sep"] revenues = [380, 410, 395, 425, 440, 460] # in lakhs # Dictionary: key-value pairs (like a lookup table) gst_rates = { "clothing": 5, "electronics": 18, "automobiles": 28, "food_basic": 0 } print(gst_rates["electronics"]) # Output: 18

Loops and Functions

# Loop: repeat an action for each item for month, rev in zip(months, revenues): print(f"{month}: ₹{rev} Lakhs") # Function: reusable block of code def calculate_tax(amount, rate_pct): """Calculate tax amount given amount and rate""" return amount * (rate_pct / 100) gst_on_electronics = calculate_tax(50000, 18) print(f"GST: ₹{gst_on_electronics:,.0f}") # Output: GST: ₹9,000

Pandas Library: The Accountant's Core Tool

Pandas is to Python what pivot tables are to Excel — but far more powerful. The central object is the DataFrame: a table with rows and columns, like a spreadsheet in code.

Reading Data

import pandas as pd # Read Excel file df = pd.read_excel("sales_data.xlsx", sheet_name="Sheet1") # Read CSV file df = pd.read_csv("gstr2a_download.csv") # Quick overview of the data print(df.shape) # (rows, columns) print(df.head(5)) # First 5 rows print(df.dtypes) # Data types of each column print(df.describe()) # Summary statistics

Filtering and Selecting Data

# Filter rows: only show invoices above ₹1 Lakh large_invoices = df[df["Invoice_Amount"] > 100000] # Multiple conditions q1_sales = df[(df["Month"].isin(["Apr", "May", "Jun"])) & (df["Status"] == "Paid")] # Select specific columns summary = df[["Vendor_Name", "Invoice_Date", "Invoice_Amount"]]

GroupBy and Pivot Table

# Sum invoices by vendor (like SUMIF) vendor_totals = df.groupby("Vendor_Name")["Invoice_Amount"].sum() # Multi-level groupby (like SUMIFS) monthly_dept = df.groupby(["Month", "Department"])["Amount"].agg(["sum", "count"]) # Pivot table pivot = pd.pivot_table(df, values="Amount", index="Month", columns="Category", aggfunc="sum", fill_value=0)

Merging DataFrames (like VLOOKUP)

# Left join — equivalent to VLOOKUP from books into GSTR-2A merged = pd.merge(books_df, gstr2a_df, on="Invoice_Number", how="left", suffixes=("_books", "_gst")) # Find unmatched records (not in GSTR-2A) unmatched = merged[merged["GSTIN_gst"].isna()]

Practical Accounting Use Cases with Code

Use Case 1: GST Reconciliation (GSTR-2A vs Books)

This is one of the most time-consuming tasks for any accounts team — matching purchase invoices in the books against what suppliers have uploaded on the GSTR-2A. A script that takes 3 minutes to run replaces 4-6 hours of manual matching.

import pandas as pd # Load data books = pd.read_excel("purchase_register.xlsx") gstr2a = pd.read_excel("gstr2a_download.xlsx") # Standardize column names books["Invoice_Number"] = books["Invoice_Number"].str.strip().str.upper() gstr2a["Invoice_Number"] = gstr2a["Invoice_Number"].str.strip().str.upper() # Merge to find matches and mismatches recon = pd.merge(books, gstr2a, on=["GSTIN", "Invoice_Number"], how="outer", suffixes=("_books", "_2A"), indicator=True) # Classify results recon["Status"] = recon["_merge"].map({ "both": "Matched", "left_only": "In Books, Not in 2A", "right_only": "In 2A, Not in Books" }) # Amount difference for matched items matched = recon[recon["Status"] == "Matched"] matched["IGST_Difference"] = matched["IGST_books"] - matched["IGST_2A"] # Summary print(recon["Status"].value_counts()) print(f"Total matched ITC: ₹{matched['IGST_2A'].sum():,.0f}") # Export result recon.to_excel("gst_reconciliation_report.xlsx", index=False)

Use Case 2: Bank Reconciliation Automation

import pandas as pd import numpy as np bank = pd.read_excel("bank_statement.xlsx") cash_book = pd.read_excel("cash_book.xlsx") # Normalize amounts — round to 2 decimal places bank["Amount"] = bank["Amount"].round(2) cash_book["Amount"] = cash_book["Amount"].round(2) # Create matching key: Date + Amount bank["Match_Key"] = bank["Date"].astype("str") + "_" + bank["Amount"].astype("str") cash_book["Match_Key"] = cash_book["Date"].astype("str") + "_" + cash_book["Amount"].astype("str") # Find unmatched items bank_only = bank[~bank["Match_Key"].isin(cash_book["Match_Key"])] books_only = cash_book[~cash_book["Match_Key"].isin(bank["Match_Key"])] print(f"Unmatched in Bank: {len(bank_only)} items, ₹{bank_only['Amount'].sum():,.0f}") print(f"Unmatched in Books: {len(books_only)} items, ₹{books_only['Amount'].sum():,.0f}")

Use Case 3: Accounts Receivable Aging Report

import pandas as pd from datetime import date ar = pd.read_excel("ar_data.xlsx") ar["Invoice_Date"] = pd.to_datetime(ar["Invoice_Date"]) today = pd.Timestamp(date.today()) # Calculate age in days ar["Age_Days"] = (today - ar["Invoice_Date"]).dt.days # Categorize by age bucket def age_bucket(days): if days <= 30: return "0-30 Days" elif days <= 60: return "31-60 Days" elif days <= 90: return "61-90 Days" elif days <= 180: return "91-180 Days" else: return "Over 180 Days" ar["Bucket"] = ar["Age_Days"].apply(age_bucket) # Summary table by customer and bucket aging_summary = ar.groupby(["Customer_Name", "Bucket"])["Outstanding_Amount"].sum().unstack(fill_value=0) print(aging_summary) aging_summary.to_excel("aging_report.xlsx")

Charts with Matplotlib and Excel Output with openpyxl

Bar Chart for P&L Visualization

import matplotlib.pyplot as plt months = ["Apr", "May", "Jun", "Jul", "Aug", "Sep"] revenue = [380, 410, 395, 425, 440, 460] expenses = [320, 345, 340, 358, 365, 378] x = range(len(months)) fig, ax = plt.subplots(figsize=(10, 5)) ax.bar([i - 0.2 for i in x], revenue, 0.4, label="Revenue", color="#3b6ef5") ax.bar([i + 0.2 for i in x], expenses, 0.4, label="Expenses", color="#e53935") ax.set_xticks(x) ax.set_xticklabels(months) ax.set_title("H1 FY25 Revenue vs Expenses (₹ Lakhs)") ax.legend() plt.tight_layout() plt.savefig("pl_chart.png", dpi=150)

Writing Formatted Excel Output

from openpyxl import Workbook from openpyxl.styles import Font, PatternFill, Alignment wb = Workbook() ws = wb.active ws.title = "Aging Report" # Header row with formatting headers = ["Customer", "0-30 Days", "31-60 Days", "61-90 Days", "Over 90 Days", "Total"] for col, header in enumerate(headers, 1): cell = ws.cell(row=1, column=col, value=header) cell.font = Font(bold=True, color="FFFFFF") cell.fill = PatternFill("solid", fgColor="1A2340") cell.alignment = Alignment(horizontal="center") # Write data rows from pandas DataFrame for row_idx, row in enumerate(aging_summary.itertuples(), 2): for col_idx, value in enumerate(row, 1): ws.cell(row=row_idx, column=col_idx, value=value) wb.save("formatted_aging_report.xlsx")

30-Day Python Learning Plan for Accountants

Week Topics Daily Practice End Goal
Week 1Variables, data types, lists, dictionaries, loops, functions30 min — Kaggle Python course, Chapters 1-4Write a function that calculates GST on a list of items
Week 2Pandas: read_excel, filtering, groupby, merge, pivot_table45 min — Kaggle Pandas course + practice on your own Excel filesLoad a real purchase register, group by vendor, export top 10
Week 3Date handling, string operations, conditional logic, openpyxl45 min — Build aging report from scratch on sample dataFully working aging report script with formatted Excel output
Week 4Matplotlib charts, putting it all together, error handling1 hour — Build one end-to-end mini projectComplete month-end summary script: data in → Excel report out

Free Resources

  • Kaggle Learn: kaggle.com/learn — Free Python and Pandas courses specifically designed for data analysis, with interactive exercises. No signup required to start.
  • CS50P (Harvard): cs50.harvard.edu/python — Harvard's free Introduction to Programming with Python. Rigorous, well-structured, certificate on completion.
  • Python for Finance (YouTube): Search "Python for finance tutorial" on YouTube — several Indian creators have built excellent free courses targeting finance professionals specifically.
  • Udemy: "Python for Financial Analysis and Algorithmic Trading" — often available for ₹500-800 during sales. Covers pandas, NumPy, and data visualization.

Student Project: Automating Month-End Close

A typical month-end close involves pulling data from 5-6 sources (bank, AR, AP, payroll, inventory), reconciling each, and producing a trial balance. A Python script can:

  1. Read all 6 source files from a folder
  2. Standardize column names and data types
  3. Run reconciliation checks (opening balance + transactions = closing balance)
  4. Flag exceptions above a materiality threshold
  5. Generate a formatted Excel summary with a traffic-light dashboard (green = reconciled, amber = minor difference, red = material difference)

A script like this, once written, reduces a 6-hour manual process to a 20-minute automated run. This is the kind of project that stands out on a resume and in interviews at finance roles in tech companies and MNCs.

⚡ Take Action Now

Open Google Colab (colab.research.google.com) right now — no installation needed. Create a new notebook, type import pandas as pd, and import one of your own Excel files using pd.read_excel(). Run your first data analysis in under 10 minutes.

Explore CorpReady Programs

📚 Real Student Story

Arjun Mehta, Finance Analyst, Bengaluru — Arjun was a CA Inter student who learned Python over 45 days using the Kaggle free courses. His first real project was automating the GST 2A reconciliation for his article firm, which was taking two staff members one full day each month. His Python script completed the same reconciliation in 4 minutes. His principal showed the script to the firm's other partners. Within 6 months of passing CA Final, Arjun received three job offers including one from a Series B fintech company at ₹14 LPA — ₹4 LPA above what his batch mates with similar scores were receiving. "I spent 45 days learning Python. The salary premium started on day one of my first job," he says.

💼 What Firms Actually Want

Genpact, WNS, Infosys BPM, and Accenture — India's largest F&A shared services employers — now list Python as a preferred or required skill in Finance Analyst job descriptions at the L3 and above levels. Deloitte and EY advisory practices explicitly ask for Python/pandas in data analytics and FDD (financial due diligence) roles. Among India's listed companies, the finance teams at Zomato, Razorpay, CRED, PhonePe, and Meesho use Python for internal financial reporting and control monitoring. For candidates targeting these roles, a GitHub profile with 2-3 public accounting automation scripts is as impactful as an additional certification. The bar is not "be a data scientist" — it is "show that you can automate your own work."

Frequently Asked Questions

✅ Key Takeaways

  • Python-skilled accountants in India earn ₹4-8 LPA more than comparable peers — the salary premium is real and growing.
  • You do not need to learn all of Python: variables, lists, dictionaries, loops, functions, and the pandas library cover 90% of accounting automation needs.
  • Pandas' groupby, merge, and pivot_table functions are the Python equivalents of SUMIFS, VLOOKUP, and pivot tables in Excel — but faster and automatable.
  • The three most valuable accounting automation projects are GST 2A reconciliation, bank reconciliation, and aging report generation — all achievable within 30 days of learning.
  • Start with Google Colab (no installation) or Anaconda/Jupyter Notebook, use the free Kaggle Python and Pandas courses, and build one real project from your own work.
  • A GitHub profile with 2-3 public accounting automation scripts is as impactful in a job interview as an additional certification for finance roles at tech companies and MNCs.

Ready to Build AI Skills for Finance?

CorpReady Academy combines cutting-edge AI/tech skills with globally recognized US CPA, CMA, ACCA & CFA credentials.

Explore CorpReady Programs Talk to a Counsellor