0

I am having trouble reading data. I am using Mac and have saved files on my desktop with the following names and can see them in the jupyter folder but cannot open them when trying with the following code. Can anyone advise ?

df_students = pd.read_excel(students.xlsx)
df_students

error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-44-14c48be800d6> in <module>
----> 1 df_students = pd.read_excel(students.xlsx)
      2 df_students

AttributeError: 'dict' object has no attribute 'xlsx'
df_census = pd.read_csv(census.csv)
df_census

error:

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-45-fe5b1bb04ec7> in <module>
----> 1 df_census = pd.read_csv(census.csv)
      2 df_census

NameError: name 'census' is not defined
Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • 1
    You should pass filenames as string, i.e. within quotes like `df_students = pd.read_excel('students.xlsx')` to read functions. – Zoro May 02 '21 at 12:28
  • Please read more about pd.read_csv [here](https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html) – Joe Ferndz May 03 '21 at 08:34
  • Does this answer your question? [Import CSV file as a pandas DataFrame](https://stackoverflow.com/questions/14365542/import-csv-file-as-a-pandas-dataframe) – Joe Ferndz May 03 '21 at 08:38

0 Answers0