S Novogoratz
S Novogoratz

Reputation: 378

Why does this while loop using a data frame attribute not work?

While I'm still learning Python, I'm just baffled by this one. This while loop gets the error: "AttributeError: 'list' object has no attribute 'empty'" and I cannot figure out why. Your help is appreciated.

import pandas as pd
import numpy as np

tickData = pd.DataFrame([])

print (tickData.empty)

while tickData.empty:
  tickData
  tickData = [1,2,3]
  print (tickData)
  
print (tickData)

Upvotes: 0

Views: 144

Answers (1)

Aparna
Aparna

Reputation: 422

Initially you had given tickData as a Dataframe and later on, you are changing that to a list datatype which is not having any attribute empty. The while loop is based upon the condition tickData.empty and hence it throws the attribute error.

Hope this helps.

Upvotes: 1

Related Questions