简体   繁体   中英

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 (ie 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!

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".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM