python - check if variable is dataframe -
when function f called variable want check if var pandas dataframe:
def f(var): if var == pd.dataframe(): print "do stuff" i guess solution might quite simple
def f(var): if var.values != none: print "do stuff" i can't work expected.
isinstance, nil else.
pep8 says explicitly isinstance preferred way check types
yes: if isinstance(obj, int): no: if type(obj) type(1): and don't think about
if obj.__class__.__name__ = "myinheritedclass": expect_problems_some_day() isinstance handles inheritance (see differences between isinstance() , type() in python). example, tell if variable string (either str or unicode), because derive basestring)
if isinstance(obj, basestring): i_am_string(obj) python pandas
No comments:
Post a Comment