title: TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe' while plotting a seaborn.regplot
body: <p>I'm trying to plot a regplot using seaborn and i'm not unable to plot it and facing <strong>TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'</strong> . </p>
  
  <p>My data has 731 rows and 16 column -</p>
  
  <pre><code>&gt;&gt;&gt; bike_df.info()
  
  &lt;class 'pandas.core.frame.DataFrame'&gt;
  RangeIndex: 731 entries, 0 to 730
  Data columns (total 16 columns):
   #   Column      Non-Null Count  Dtype  
  ---  ------      --------------  -----  
   0   instant     731 non-null    int64  
   1   dteday      731 non-null    object 
   2   season      731 non-null    int64  
   3   yr          731 non-null    int64  
   4   mnth        731 non-null    int64  
   5   holiday     731 non-null    int64  
   6   weekday     731 non-null    int64  
   7   workingday  731 non-null    int64  
   8   weathersit  731 non-null    int64  
   9   temp        731 non-null    float64
   10  atemp       731 non-null    float64
   11  hum         731 non-null    float64
   12  windspeed   731 non-null    float64
   13  casual      731 non-null    int64  
   14  registered  731 non-null    int64  
   15  cnt         731 non-null    int64  
  dtypes: float64(4), int64(11), object(1)
  memory usage: 88.6+ KB
  </code></pre>
  
  <p>Here is a snippet of the data 
  <a href="https://i.stack.imgur.com/NmEXG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NmEXG.png" alt="data snippet"></a>
  And when i'm trying to plot regplot using seaborn -</p>
  
  <pre><code>&gt;&gt;&gt; sns.regplot(x="casual", y="cnt", data=bike_df);
  
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-54-68533af96906&gt; in &lt;module&gt;
  ----&gt; 1 sns.regplot(x="casual", y="cnt", data=bike_df);
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\regression.py in regplot(x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, seed, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, label, color, marker, scatter_kws, line_kws, ax)
      816     scatter_kws["marker"] = marker
      817     line_kws = {} if line_kws is None else copy.copy(line_kws)
  --&gt; 818     plotter.plot(ax, scatter_kws, line_kws)
      819     return ax
      820 
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\regression.py in plot(self, ax, scatter_kws, line_kws)
      363 
      364         if self.fit_reg:
  --&gt; 365             self.lineplot(ax, line_kws)
      366 
      367         # Label the axes
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\regression.py in lineplot(self, ax, kws)
      406         """Draw the model."""
      407         # Fit the regression model
  --&gt; 408         grid, yhat, err_bands = self.fit_regression(ax)
      409         edges = grid[0], grid[-1]
      410 
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\regression.py in fit_regression(self, ax, x_range, grid)
      214             yhat, yhat_boots = self.fit_logx(grid)
      215         else:
  --&gt; 216             yhat, yhat_boots = self.fit_fast(grid)
      217 
      218         # Compute the confidence interval at each grid point
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\regression.py in fit_fast(self, grid)
      239                                     n_boot=self.n_boot,
      240                                     units=self.units,
  --&gt; 241                                     seed=self.seed).T
      242         yhat_boots = grid.dot(beta_boots).T
      243         return yhat, yhat_boots
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\algorithms.py in bootstrap(*args, **kwargs)
       83     for i in range(int(n_boot)):
       84         resampler = integers(0, n, n)
  ---&gt; 85         sample = [a.take(resampler, axis=0) for a in args]
       86         boot_dist.append(f(*sample, **func_kwargs))
       87     return np.array(boot_dist)
  
  ~\AppData\Local\Continuum\anaconda3\envs\rstudio\lib\site-packages\seaborn\algorithms.py in &lt;listcomp&gt;(.0)
       83     for i in range(int(n_boot)):
       84         resampler = integers(0, n, n)
  ---&gt; 85         sample = [a.take(resampler, axis=0) for a in args]
       86         boot_dist.append(f(*sample, **func_kwargs))
       87     return np.array(boot_dist)
  
  TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'
  </code></pre>
  
  <p>I tried changing the datatypes using dtypes for all the rows like below - </p>
  
  <pre><code>&gt;&gt;&gt; bike_df['cnt'] = bike_df['cnt'].astype(np.int32)
  </code></pre>
  
  <p>but this did not help and got the same error again while plotting.</p>
  
  <p>Any suggestions are appreciated.</p>
  
  <p>Thanks in advance.</p>