Skip to content

Commit

Permalink
Use isinstance instead of comparing types with ==
Browse files Browse the repository at this point in the history
  • Loading branch information
kshedden committed Nov 3, 2018
1 parent f0474f6 commit 83725a0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions statsmodels/genmod/generalized_estimating_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,23 +679,23 @@ def from_formula(cls, formula, groups, data, subset=None,
""" % {'missing_param_doc': base._missing_param_doc}

groups_name = "Groups"
if type(groups) == str:
if isinstance(groups, str):
groups_name = groups
groups = data[groups]

if type(time) == str:
if isinstance(time, str):
time = data[time]

if type(offset) == str:
if isinstance(offset, str):
offset = data[offset]

if type(exposure) == str:
if isinstance(exposure, str):
exposure = data[exposure]

dep_data = kwargs.get("dep_data")
dep_data_names = None
if dep_data is not None:
if type(dep_data) is str:
if isinstance(dep_data, str):
dep_data = patsy.dmatrix(dep_data, data, return_type='dataframe')
dep_data_names = dep_data.columns.tolist()
else:
Expand Down Expand Up @@ -2320,7 +2320,7 @@ def setup_nominal(self, endog, exog, groups, time, offset):
jrow += 1

# exog names
if type(self.exog_orig) == pd.DataFrame:
if isinstance(self.exog_orig, pd.DataFrame):
xnames_in = self.exog_orig.columns
else:
xnames_in = ["x%d" % k for k in range(1, exog.shape[1] + 1)]
Expand All @@ -2331,7 +2331,7 @@ def setup_nominal(self, endog, exog, groups, time, offset):
exog_out = pd.DataFrame(exog_out, columns=xnames)

# Preserve endog name if there is one
if type(self.endog_orig) == pd.Series:
if isinstance(self.endog_orig, pd.Series):
endog_out = pd.Series(endog_out, name=self.endog_orig.name)

return endog_out, exog_out, groups_out, time_out, offset_out
Expand Down

0 comments on commit 83725a0

Please sign in to comment.