Kumar Chandan
Kumar Chandan

Reputation: 11

name 'df' is not defined in box plot

I am trying to plot box plot with some data, but I am getting name 'df' is not defined error. Below is the code:

import numpy as np  
import pandas as pd  
from matplotlib import pyplot as plt
import os
% matplotlib inline

# load the dataset 
df = pd.read_csv("C:/Users/Kumar Chandan/Downloads/indiavix.csv") 

# display 5 rows of dataset 
df.head()

df=df.boxplot(column =['close'], grid = False) 

Upvotes: 0

Views: 1287

Answers (2)

Minu
Minu

Reputation: 61

Don't assign value again to data frame. In place of assigning use

df.boxplot(column =['close'], grid = False) 

Upvotes: 2

scign
scign

Reputation: 942

You need to use

df.boxplot(column =['close'], grid = False)

By putting df = at the front of that line you are assigning the output of the line (the plot) back to df which erases your dataframe.

Upvotes: 5

Related Questions