hauncher
hauncher

Reputation: 23

Load a csv file into pandas dataframe

First question: please be kind.

I am having trouble loading a CSV file into a DataFrame on Spyder, using iPython. When I load an XLS file, it seems to have no problem and populates the new DataFrame variable into the variable explorer.

For example:

import pandas as pd
energy = pd.read_excel('file.xls', skiprows=17)

The above returns a DataFrame, named energy, populated in the variable explorer (i.e. I can actually see the DataFrame).

However, when I try to load in a CSV file using the same method, it seems to read in the file, however it does not populate the variable explorer.

For example:

import pandas as pd
GDP = pd.read_csv('file.csv')

When I run the above line, I don't get an error message, but the new DataFrame, GDP, does not populate the variable explorer. If I print GDP I get the values (268 rows x 60 columns). Am I not saving the new DataFrame correctly as a variable?

Thanks!

Upvotes: 2

Views: 8386

Answers (1)

DYZ
DYZ

Reputation: 57085

The problem is not with the variable, but with the way Variable Explorer filters what it shows. Go to "Tools/Preferences", select "Variable explorer", and uncheck option "Exclude all-uppercase references".

Upvotes: 3

Related Questions