I've read a CSV file into Jupyter Notebook and I'm trying to remove redundant columns I'm not gonna use. I'm using the drop() method but its giving me a NameError! I'm sure the columns exist and I feel Like I'm missing something obvious here but i can't seem to figure it out.
So here is my code so far:
#Calling Libraries
import os # File management
import pandas as pd # Data frame manipulation
import numpy as np # Data frame operations
import datetime as dt # Date operations
import seaborn as sns # Data Viz
flight_df=pd.read_csv(r'C:\Users\pc\Desktop\Work\flights.csv')
# removing na rows
flight_df.dropna()
# dropping redundant columns
newdf=flight_df.drop([O_COUNTRY,O_LATITUDE,O_LONGITUDE,D_COUNTRY,D_LATITUDE,D_LONGITUDE,SCHEDULED_DEPARTURE,DIVERTED,CANCELLED,CANCELLATION_REASON,TAXI_OUT,TAXI_IN,WHEELS_OFF, WHEELS_ON,SCHEDULED_ARRIVAL],axis=1, inplace = True)
throws this error:
NameError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_15328/4119461383.py in 2 flight_df.dropna() 3 # dropping redundant columns newdf=flight_df.drop([O_COUNTRY,O_LATITUDE,O_LONGITUDE,D_COUNTRY,D_LATITUDE,D_LONGITUDE,SCHEDULED_DEPARTURE,DIVERTED,CANCELLED,CANCELLATION_REASON,TAXI_OUT,TAXI_IN,WHEELS_OFF, WHEELS_ON,SCHEDULED_ARRIVAL],axis=1, inplace = True)
NameError: name 'O_COUNTRY' is not defined
I have tried to instead define the ones i want to keep but it's giving me the same error