Member-only story

How to drop columns from a Pandas DataFrame — with examples.

Josh Otwell
4 min readSep 25, 2019

--

I use Pandas — and Python in general — for any type of scripting. Having grown to loathe redundant menial tasks, especially with CSV’s, I lean more and more on this powerful library. Since I manipulate and use them (CSV’s) daily at work, if I perform a routine 3 times, it finds its way into a Python script with pandas leading the charge. More often than not, when analyzing CSV data, they tend to be messy. Likely they have columns you don’t need or care about. Pandas DataFrames have a function that allows you to get rid of those columns and keep only the ones you need. As always, I learn best by example so keep reading and learn with me…

Photo by Ali Lokhandwala on Unsplash

OS, Database, and software used:

  • OpenSuse Leap 15.0
  • Python 3.7.2

Self-Promotion:

If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!

Far from in shape, I still walk a lot. Typically I walk or hike at least an hour a day, 6 days a week. I track certain stats from my walks for a month in — you guessed it — a CSV file. The example CSV below contains some columns I want to keep and others I don’t. How can I get rid…

--

--

Josh Otwell
Josh Otwell

Written by Josh Otwell

SQL/PHP | Photography | Technical Consultant. Sign-up for my free developer newsletter, OpenLampTech, here: openlamptech.substack.com

No responses yet