Home ยป pandas

pandas

Undersampling a Pandas DataFrame

  • by
  • 2 min read

In a previous post, I explained how you can sample two Pandas DataFrame exactly the same way. In this blog post, I want to use that helper function to undersample your predictors and target variable. When you are working with an imbalanced data set, it’s often good practice to under-… 

How to solve SettingWithCopyWarning when using the ‘inplace’ parameter in pandas

  • by
  • 2 min read

The SettingWithCopyWarning message is a confusing warning to many who are new to Pandas. If you’ve ever taken a computer science course, you might be aware of passing/copying by value or by reference. Well, it very much applies to pandas DataFrames too. Let’s go. Basically, when you are slicing a… 

How to: pandas – drop column

  • by
  • 3 min read

There are many ways to remove a column in a pandas DataFrame. However, some ways are better than others. In this blog post, I elaborate on multiple solutions and what the pros and cons are. First, let’s load the iris dataset from the Seaborn package on GitHub. Drop a pandas…