Fundamentals 13 min read

Master Data Analysis with Python: From Excel/SQL to Pandas in 10 Steps

This tutorial walks data analysts through transitioning from Excel and SQL to Python, covering environment setup, data import with pandas, web scraping, cleaning, renaming, type conversion, filtering, grouping, merging, and visualization using Jupyter Notebook and popular libraries.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Data Analysis with Python: From Excel/SQL to Pandas in 10 Steps

01 Import Data

Python can import data from many sources, including .sql databases, Excel files, CSV, HTML tables, and web pages. The pandas library provides read_* functions to load these formats directly into DataFrames.

02 Trust the Website Code

Use the requests library to fetch HTML content and BeautifulSoup to parse tables, such as the Wikipedia list of per‑capita GDP, then sort the data with pandas.

03 Quick Data Preview

Call df.head() to display the first rows of a DataFrame, similar to Excel’s row selection or SQL’s LIMIT clause.

04 Rename Columns

Rename columns with df.rename(columns={'US $':'gdp_per_capita'}) and verify the change using head().

05 Delete Columns

Remove unwanted columns using the del statement, e.g., del df['Rank'], then confirm with another head() call.

06 Convert Data Types

Clean string values using regular expressions ( re.sub) to strip commas, then convert columns to numeric types with pandas, enabling calculations like averaging.

07 Select/Filter Data

Apply boolean indexing to filter rows, e.g., df[df['gdp_per_capita'] > 50000], combine conditions with & (AND) and | (OR), and filter by string patterns.

08 Compute Results

Perform arithmetic operations on numeric columns, such as summing GDP values above a threshold, leveraging pandas’ integration with numpy.

09 Data Visualization

Create charts with seaborn or matplotlib; for example, a histogram ( df['gdp_per_capita'].hist()) shows the distribution of high‑GDP countries.

10 Group and Merge Data

Use df.merge() to join the GDP DataFrame with a World Development Indicators CSV, then group by region with df.groupby('Region'), pivot tables, and drop() to clean the final dataset.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythondata analysisData visualizationJupyter Notebook
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.