title: ValueError Input contains NaN, infinity or a value too large for dtype('float64') Scitkit Learn
body: <p>I have read through so many posts regarding this and cannot find my answer.</p>
  
  <pre><code>import pandas as pd
  </code></pre>
  
  <p>After import pandas, I read a csv file using pandas.read_csv. The csv file has 32 columns and ~280,000 rows.</p>
  
  <pre><code>data = pd.read_csv(path)
  # Add unique index column to data
  data = data.reset_index()
  </code></pre>
  
  <p>I then use the pandas.dropna function to ensure my data doesn't have any nan values.</p>
  
  <pre><code>dropped_values = data.dropna(inplace=True)
  print(dropped_value.dtypes)
  # returns all float64 types
  </code></pre>
  
  <p><strong>Also checked these from popular upvoted answer</strong></p>
  
  <pre><code>np.any(np.isnan(dropped_values))
  # prints false
  np.all(np.isfinite(dropped_values))
  # prints true
  </code></pre>
  
  <p><strong>and yet I still receive</strong> </p>
  
  <pre><code>ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
  </code></pre>
  
  <p>...</p>
  
  <pre><code>ValueError                                Traceback (most recent call last)
      &lt;ipython-input-75-f81bb23d00b2&gt; in &lt;module&gt;
       76 
       77 
       ---&gt; 78 for train_index, test_index in strat_split.split(dropped_values, 
       dropped_values["time_attribute"]):
  </code></pre>
  
  <p>from the line with the for loop</p>
  
  <pre><code>strat_split = StratifiedShuffleSplit(n_splits=1, test_size=0.25, random_state=42)
  
  dropped_values["time_attribute"] = pd.cut(dropped_values["Time"], 
                                         bins=[0., 35000, 70000, 105000, 140000, 175000., np.inf],
                                         labels=[1, 2, 3, 4, 5, 6])
  
  
  for train_index, test_index in strat_split.split(dropped_values, dropped_values["time_attribute"]):
      strat_train_set = dropped_values.loc[train_index]
      strat_test_set = dropped_values.loc[test_index]
  </code></pre>
  
  <p>I have also tried imputing the data using SimpleImputer before I try to call the StartifySplit.
  Additionally, I have tried many other variations of dropna found in other posts' comments and nothing seems to work. </p>
  
  <p>This doesn't make sense because I have viewed the data, printed the data types, check whether they are nan or finite and everything is giving the correct answer.</p>
  
  <p><strong>Anybody have any other suggestions to try?</strong></p>
  
  <p>Please note I changed the variable names in my post to make it more generic. If I accidentally missed a letter/character it was probably just a mistake while creating the post.</p>