enter image description here

def get_significant_vars(lm):
    var_p_vals_df=pd.DataFrame( lm.pvalues )
    var_p_vals_df['vars']= var_p_vals_df.index
    var_p_vals_df.colums= ['pvals','vars']
    #filter the column name where p value is less than 0.05
    return list( var_p_vals_df[var_p_vals_df.pvals <= 0.05]['vars'])

invoking above method get_significant_vars we should get the list of significant variables with p value less than 0.05 where we find following error

significant_vars = get_significant_vars( logit_model )
significant_vars

Error:C:\Users\dell\Anaconda3\lib\site-packages\ipykernel_launcher.py:4: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
  after removing the cwd from sys.path.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-117-985ab2e4e2a1> in <module>
----> 1 significant_vars = get_significant_vars( logit_model )
      2 significant_vars

<ipython-input-116-ea9aca6d9445> in get_significant_vars(lm)
      4     var_p_vals_df.colums= ['pvals','vars']
      5     #filter the column name where p value is less than 0.05
----> 6     return list( var_p_vals_df[var_p_vals_df.pvals <= 0.05]['vars'])
      7 

~\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
   5065             if self._info_axis._can_hold_identifiers_and_holds_name(name):
   5066                 return self[name]
-> 5067             return object.__getattribute__(self, name)
   5068 
   5069     def __setattr__(self, name, value):

AttributeError: 'DataFrame' object has no attribute 'pvals'

Related posts

Recent Viewed