How to export a Python DataFrame to a csv file?

In today’s data analysis tutorial we’ll go through a very simple recipe for exporting a Pandas DataFrame to a comma separated value (csv) file. This is specially useful feature that allows us once we finish to clean our raw data to persist the result in a handy file. Save Pandas DataFrame to file example Create … Read more

Find index of Pandas row values in Python dataframe columns

In today’s tutorial we’ll learn how to easily find the index values of specific rows in Pandas DataFrames which answer specific condition. We’ll be looking at Preparations We’ll start by importing Pandas and Numpy, then we’ll go ahead and create some example data. Here’s our DataFrame Find index of specific column value The result will … Read more

How to drop columns by index from a Python DataFrame?

In this short tutorial we’ll learn how to delete one or multiple DataFrame columns using their respective columns index. Example data Let’s start by defining a simple example DataFrame: Let’s look at the column index. Type the following code: You’ll get back the column index, which we’ll use to write code for the use cases … Read more

How to rename one or more Python Pandas DataFrame columns?

When working with tabular data that was acquired from different sources, you might need to tidy it up by modifying column names. In today’s tutorial we’ll learn to use the DataFrame.rename() method of the Pandas library which as you can infer, helps renaming both rows and columns index in your DataFrame. Create Example DataFrame Let … Read more