0

I am attempting to change column names with the following code:

import pandas as pd


jeopardy = pd.read_csv('/Users/adamshaw/Desktop/Coding/jeopardy_starting/jeopardy.csv')

jeopardy = jeopardy.rename(columns={' Air Date': 'Air_Date',
                                    ' Round': 'Round'}, inplace=True)

print(jeopardy)

I am getting the following output:

>>> None

How do I properly rename the columns?

these are the columns

Show Number    int64 
 Air Date      object
 Round         object
 Category      object
 Value         object
 Question      object
 Answer        object
Martin Gergov
  • 1,455
  • 4
  • 18
  • 27

1 Answers1

0

You are using the inplace=True option when renaming your columns. This returns nothing (None type) which you are assigning to the jeopardy variable.

Try removing the inplace=True or don't reassign it to jeopardy. So either

jeopardy = jeopardy.rename(columns={' Air Date': 'Air_Date',
                                    ' Round': 'Round'})

or

jeopardy.rename(columns={' Air Date': 'Air_Date',
                         ' Round': 'Round'}, inplace=True)
Daniel Lima
  • 775
  • 1
  • 6
  • 19