Pandas: Rename a single column

There are several ways that you can rename multiple column names. But most of them requires specifying all of the column names, which can be time-consuming to create. What if you want to rename just one column? There are a few ways to do that. One of them involves passing a dictionary to df.rename(). The … Read more

Pandas: How to rename columns

Summary: in this tutorial, you’ll learn about how to rename columns of a DataFrame. String operation on column names Column names of a DataFrame are basically strings wrapped in Index object. You can easily cast the df.columns to a Python list for later usage if needed. Pandas support string operations directly on DataFrame columns. In … Read more

Pandas: How to reorder columns

Summary: in this tutorial, you’ll learn about how to reorder and swap columns on a DataFrame. Reorder columns There are two ways you can reorder columns in Pandas. Basically you have to align your DataFrame to another column labels. Let’s see a simple example. month year sale a 1 2012 55 b 4 2014 40 … Read more