Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DF is not defined
#1
I wrote this code for some uni work, was all working fine then when i logged in this morning to try it again i get "DF is not defined" Can anyone see why at all?

import pandas as pd
import csv as df

df = pd.read_csv("/Users/maddieroberts/Desktop/code/university_picker/course_data.csv")

def read_data_base(filename):
    """
    A function to read data
    """
    return pd.read_csv("/Users/maddieroberts/Desktop/code/university_picker/course_data.csv")

def build_boolean_index(df, criteria):
    """
    A function used to input an individuals preferences for university
    """
    indices = [df[key] == value for key, value in criteria.items()]
    index = indices[0]
    for column in indices[1:]:
        index = index & column
    return index

def get_choice(df, criteria):
    """
    A function to return the options calculated from the previous boolean

    """
    index = build_boolean_index(df, criteria)
    return df[index]
Reply
#2
Please, post the full traceback you get, in error tags
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020