Here's the fastest way to use Python if you already know SQL:

@tommitchelldata
Tom Mitchell@tommitchelldata
14 views Mar 14, 2024 ~2 min read
Advertisement
1
Here's the fastest way to use Python if you already know SQL:
2
SQL is great for querying databases, while Python's power lies in its versatility for data manipulation and analysis.

By adding Python to your toolkit, you'll unlock a wider range of tools and libraries.
3
If you've not encountered it before, start with Python (and programming) fundamentals.

Get a grasp on variables, data types, and control structures.

This will give you a great platform to kick on.
4
Python offers fantastic libraries like Pandas and NumPy for data manipulation.

Pandas, in particular, mirrors SQL-like operations and makes it easier to work with tabular data (data in table form).
5
In SQL, you query databases.

In Python, use Pandas' read_csv() or read_excel() functions to import data from files.

For databases, libraries like SQLAlchemy connect Python with various database systems.
6
In SQL, you use WHERE and ORDER BY.

In Pandas, use df[df['column'] condition] for filtering and df.sort_values('column') for sorting.

Once you've grasped it, you won't forget it.
7
SQL joins combine data from different tables.

In Pandas, merge() and join() functions accomplish this.

Understanding the types of joins is crucial—inner, outer, left, right—to replicate SQL behaviour.
8
For aggregation (GROUP BY in SQL), Pandas' groupby() is your go-to.

Combined with functions like sum(), mean(), you can perform SQL-like summarisations.
9
Subqueries' equivalent is a bit different.

Use Pandas' isin() and query() for subquery-like operations.

Window functions?

Pandas' .rolling() and .expanding() are your go-to.
10
Python's Matplotlib and Seaborn libraries help create stunning visualisations.

SQL lacks this power, giving you a new edge in presenting insights.
11
If you want to read more about how I used Python as a data analyst, I wrote a full article on it which you can read for free here:trend-labs.co.uk/blog/4-ways-i-…

If you enjoyed this thread consider following me:

@tommitchelldata

for more data-related content every day.
Actions
What You Can Do
  • Export as PDF or Markdown
  • Batch Export to Notion
  • Bookmark & Highlight
  • LinkedIn & Instagram Carousel Maker
Create Free Account

Includes 7-day Premium trial

Advertisement