title: Question on Python Feature Selection (null values)
body: <p>I'm building a logistic regression model, and want to understand the features that contribute the most to my output (1 or 0). Trying to understand if a customer comes back to my website, what features are making them come back. I am getting stuck with this fit function. It errors out on me and I can't figure out why. It seems to indicate that I have some null values, but I've scrubbed through my data and removed the null values. </p>
  
  <pre><code>import pandas as pd
  import numpy as np
  from sklearn import preprocessing
  import matplotlib.pyplot as plt
  from sklearn.feature_selection import SelectKBest
  from sklearn.feature_selection import chi2
  
  #load data
  df = pd.read_csv('jupyter.csv', header = 0)
  array = dataframe.values
  X = array[:,1:13]
  Y = array[:,14]
  print (X.shape)
  print (Y.shape)
  (544219, 12)
  (544219,)
  
  # feature extraction
  test = SelectKBest(score_func=chi2, k=4)
  fit = test.fit(X, Y)
  </code></pre>
  
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-63-f91db4d08897&gt; in &lt;module&gt;
        1 # feature extraction
        2 test = SelectKBest(score_func=chi2, k=4)
  ----&gt; 3 fit = test.fit(X, Y)
        4 # summarize scores
        5 #numpy.set_printoptions(precision=3)
  
  /opt/anaconda3/lib/python3.7/site-packages/sklearn/feature_selection/univariate_selection.py in fit(self, X, y)
      339         self : object
      340         """
  --&gt; 341         X, y = check_X_y(X, y, ['csr', 'csc'], multi_output=True)
      342 
      343         if not callable(self.score_func):
  
  /opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)
      720     if multi_output:
      721         y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,
  --&gt; 722                         dtype=None)
      723     else:
      724         y = column_or_1d(y, warn=True)
  
  /opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
      540         if force_all_finite:
      541             _assert_all_finite(array,
  --&gt; 542                                allow_nan=force_all_finite == 'allow-nan')
      543 
      544     if ensure_min_samples &gt; 0:
  
  /opt/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py in _assert_all_finite(X, allow_nan)
       58     elif X.dtype == np.dtype('object') and not allow_nan:
       59         if _object_dtype_isnan(X).any():
  ---&gt; 60             raise ValueError("Input contains NaN")
       61 
       62 
  ValueError: Input contains NaN
  </code></pre>