Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Follow publication

Member-only story

Refactoring Data Science Python Code With Chat GPT

Adam Ross Nelson
Level Up Coding
Published in
8 min readJul 7, 2023

--

Introduction

Hello fellow data + coding enthusiasts!

One of the joys of working with data is the endless possibility for learning, improvement, and innovation. Recently, one tool has helped me revisit and revitalize my Python code in exciting ways — Chat GPT.

Bet ya didn’t see that one coming, didja?

Yes, I use ChatGPT for a plethora of tasks and I’ve found it to be useful when used thoughtfully… in moderation… and with care. I’ve explored various uses, but today, I want to share with you a unique application that seems to be growing in popularity based on my review of social media and discussion boards.

I too have quickly grown fond of — refactoring and revising Python code. This article provides examples.

Spoiler: ChatGPT fumbled BIG TIME on the data visualization example.

The Setting

Imagine those early days, the nascent beginnings of your coding journey. You’ve probably got some old Python code tucked away in the vast landscape of the internet — I know I do. How about dusting off those files and introducing them to ChatGPT?

You can ask ChatGPT to refactor your old code plus add or revise inline comments. This is both about improving the code, and also about…

--

--

Written by Adam Ross Nelson

Ask about my free career course. I mentor new (💫) and aspiring data scientists enter (🚪) and level up (📈) in the field.

Write a response