Jun-12-2020, 09:21 AM
Oh! I just got a lesson by isinstance this function.
Thank for your assistance.
Thank for your assistance.
(Jun-12-2020, 08:47 AM)buran Wrote: you compare type of the object with str object - that's why it's false.
As per the docs and also PEP8 recommendation, theisinstance()
built-in function is recommended for testing the type of an object, because it takes subclasses into account.
import pandas as pd spam = [1,2,3] df = pd.DataFrame(spam) # better use isinstance() print(isinstance(df, pd.DataFrame)) print(isinstance(spam, list))