Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Follow publication

Member-only story

8 Essential Python Techniques for Data Engineers and Analysts (with code samples)

6 min readJan 17, 2022

--

Even the most experienced coders google stuff.

I re-google simple lines of code that I use all the time just as a quick reminder of syntax. In that sense, I’m really writing this article for myself. These are the most common pieces of Python code that I re-use over and over again as a Data Generalist.

(All the below examples are done using Python 3.6 or later)

Querying Data from a DB into a Pandas DataFrame or a CSV file

When SQL isn’t sufficient for an analysis or a complex data transformation, Python is probably the answer. But before you can wrangle any data, you have to get the data into memory so you can do stuff with it. Using PYODBC if you’re database is on MS SQL Server or PSYCOPG2 if you’re on Postgres, you can write queries and pull data easily using Python. From there it’s just a matter of getting your data into a format that’s easy to work with. For this I like Pandas. Getting the query data into Pandas is as simple as converting the list to a CSV and then using the pandas…

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Cameron Warren
Cameron Warren

Written by Cameron Warren

Writing about how teams and individuals can more effectively use data. Follow me: @camwarrenm