title: TypeError: 'range' object is not callable
body: <p>I have been plotting some plots and then I received the above error for the code below:</p>
  
  <pre><code>    lag = range(0, 31)
      djia_acf = []
      for l in lag:
          djia_acf.append(djia_df['Close'].autocorr(l))
  
  
      plt.figure(figsize = (5.5, 5.5))
      g = sns.pointplot(x=lag, y=djia_acf, markers = '.')
      g.set_title('Autocorrelation function for DJIA')
      g.set_xlabel('Lag in terms of number of trading days')
      g.set_ylabel('Autocorrelation Function')
      g.set_xticklabels(lag, rotation = 90)
  
  TypeError                            Traceback (most recent call last)
  &lt;ipython-input-42-3ca28bdcaeea&gt; in &lt;module&gt;()
        1 plt.figure(figsize = (5.5, 5.5))
  ----&gt; 2 g = sns.pointplot(x=lag, y=djia_acf, markers = '.')
        3 g.set_title('Autocorrelation function for DJIA')
        4 g.set_xlabel('Lag in terms of number of trading days')
        5 g.set_ylabel('Autocorrelation Function')
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py in pointplot(x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, markers, linestyles, dodge, join, scale, orient, color, palette, ax, errwidth, capsize, **kwargs)
     3065                             estimator, ci, n_boot, units,
     3066                             markers, linestyles, dodge, join, scale,
  -&gt; 3067                             orient, color, palette, errwidth, capsize)
     3068 
     3069     if ax is None:
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py in __init__(self, x, y, hue, data, order, hue_order, estimator, ci, n_boot, units, markers, linestyles, dodge, join, scale, orient, color, palette, errwidth, capsize)
     1607         """Initialize the plotter."""
     1608         self.establish_variables(x, y, hue, data, orient,
  -&gt; 1609                                  order, hue_order, units)
     1610         self.establish_colors(color, palette, 1)
     1611         self.estimate_statistic(estimator, ci, n_boot)
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py in establish_variables(self, x, y, hue, data, orient, order, hue_order, units)
      201                 # Group the numeric data
      202                 plot_data, value_label = self._group_longform(vals, groups,
  --&gt; 203                                                               group_names)
      204 
      205                 # Now handle the hue levels for nested ordering
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/seaborn/categorical.py in _group_longform(self, vals, grouper, order)
      243 
      244         # Group the val data
  --&gt; 245         grouped_vals = vals.groupby(grouper)
      246         out_data = []
      247         for g in order:
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, **kwargs)
     4269         return groupby(self, by=by, axis=axis, level=level, as_index=as_index,
     4270                        sort=sort, group_keys=group_keys, squeeze=squeeze,
  -&gt; 4271                        **kwargs)
     4272 
     4273     def asfreq(self, freq, method=None, how=None, normalize=False,
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/pandas/core/groupby.py in groupby(obj, by, **kwds)
     1624         raise TypeError('invalid type: %s' % type(obj))
     1625 
  -&gt; 1626     return klass(obj, by, **kwds)
     1627 
     1628 
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/pandas/core/groupby.py in __init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, **kwargs)
      390                                                     level=level,
      391                                                     sort=sort,
  --&gt; 392                                                     mutated=self.mutated)
      393 
      394         self.obj = obj
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/pandas/core/groupby.py in _get_grouper(obj, key, axis, level, sort, mutated)
     2636                         sort=sort,
     2637                         in_axis=in_axis) \
  -&gt; 2638             if not isinstance(gpr, Grouping) else gpr
     2639 
     2640         groupings.append(ping)
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/pandas/core/groupby.py in __init__(self, index, grouper, obj, name, level, sort, in_axis)
     2418                     t = self.name or str(type(self.grouper))
     2419                     raise ValueError("Grouper for '%s' not 1-dimensional" % t)
  -&gt; 2420                 self.grouper = self.index.map(self.grouper)
     2421                 if not (hasattr(self.grouper, "__len__") and
     2422                         len(self.grouper) == len(self.index)):
  
  /home/aspiring1/anaconda3/lib/python3.6/site-packages/pandas/core/indexes/base.py in map(self, mapper)
     2725         """
     2726         from .multi import MultiIndex
  -&gt; 2727         mapped_values = self._arrmap(self.values, mapper)
     2728         attributes = self._get_attributes_dict()
     2729         if mapped_values.size and isinstance(mapped_values[0], tuple):
  
  pandas/_libs/algos_common_helper.pxi in pandas._libs.algos.arrmap_int64 (pandas/_libs/algos.c:41758)()
  
  TypeError: 'range' object is not callable
  
  &lt;matplotlib.figure.Figure at 0x7f1fa7c2ab70&gt;
  </code></pre>
  
  <p>In the above code I'm just trying to plot a pointplot using seaborn, but it is giving error of range object isn't callable, I've seen a similar post which had the error </p>
  
  <blockquote>
    <p>"list object is not callable"</p>
  </blockquote>
  
  <p>But, here I can't see anywhere where my range object <strong>lag</strong> has been called.
  Using x = np.array(lag) gives me the required plot with the below output as extra, don't know why?</p>
  
  <pre><code>[&lt;matplotlib.text.Text at 0x7f1fa7d38208&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7d38ef0&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c61208&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c61cc0&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c696d8&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c711d0&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c71c88&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c75780&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c7c278&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c7cd30&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c02828&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c08320&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c08dd8&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c0c8d0&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c123c8&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c12e80&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c1a978&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c1e470&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c1ef28&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c25a20&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c2a518&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c2afd0&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c31ac8&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c385c0&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c3d0b8&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7c3db70&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7bc5668&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7bc9160&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7bc9c18&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7bce710&gt;,
   &lt;matplotlib.text.Text at 0x7f1fa7bd4208&gt;]
  </code></pre>
  
  <p>I've made plots using matplotlib.pyplot which take range object as x values as given below:</p>
  
  <pre><code>inflation = pd.read_excel('inflation-consumer-prices-annual.xlsx', parse_dates=['Year'])
  plt.figure(figsize=(5.5, 5.5))
  plt.plot(range(1960,2017), inflation['India'], linestyle='-', marker='*',
  color='r')
  plt.plot(range(1960,2017), inflation['United States'], linestyle='-',
  marker='.', color='b')
  plt.legend(['India','United States'], loc=1)
  plt.title('Inflation in Consumer Price Index')
  plt.ylabel('Inflation')
  plt.xlabel('Years')
  </code></pre>
  
  <p>Thus, I can't why I am getting the TypeError, since it works with matplotlib.pyplot and range object being called doesn't make any sense.</p>