0

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)
2
  • 2
    You are changing tickData from a dataframe to a list with tickData=[1,2,3], which doesn't support .empty Commented Jul 8, 2020 at 18:54
  • you redefine tickData with every iteration and your list doesn't have an .empty method Commented Jul 8, 2020 at 18:54

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.