Code Monkey home page Code Monkey logo

pydata_pandas's Issues

data.plot(x=data.Tenure, style=".-")

KeyError: "None of [Int64Index([ 2, 1, 8, 1, 2, 8, 7, 4, 4, 2,\n ...\n 3, 4, 2, 7, 2, 5, 10, 7, 3, 4],\n dtype='int64', length=10000)] are in the [columns]"
Screenshot (4393)

Plot gives 'not in index' error

i have followed your steps exactly as you are showing, but the data frame plots did not work. I have reloaded the jupyter notebook and re-run every code in sequence, I have matplotlib installed and imported too. Please help me with this error.

It gives a long error as shown below;
.....................................................................................................................................................................
KeyError Traceback (most recent call last)
in ()
----> 1 data.plot(x=data.timestamp)

/anaconda3/lib/python3.6/site-packages/pandas/plotting/_core.py in call(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
2939 fontsize=fontsize, colormap=colormap, table=table,
2940 yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2941 sort_columns=sort_columns, **kwds)
2942 call.doc = plot_frame.doc
2943

/anaconda3/lib/python3.6/site-packages/pandas/plotting/_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
1975 yerr=yerr, xerr=xerr,
1976 secondary_y=secondary_y, sort_columns=sort_columns,
-> 1977 **kwds)
1978
1979

/anaconda3/lib/python3.6/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
1764 if is_integer(x) and not data.columns.holds_integer():
1765 x = data_cols[x]
-> 1766 elif not isinstance(data[x], ABCSeries):
1767 raise ValueError("x must be a label or position")
1768 data = data.set_index(x)

/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in getitem(self, key)
2680 if isinstance(key, (Series, np.ndarray, Index, list)):
2681 # either boolean or fancy integer index
-> 2682 return self._getitem_array(key)
2683 elif isinstance(key, DataFrame):
2684 return self._getitem_frame(key)

/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_array(self, key)
2724 return self._take(indexer, axis=0)
2725 else:
-> 2726 indexer = self.loc._convert_to_indexer(key, axis=1)
2727 return self._take(indexer, axis=1)
2728

/anaconda3/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter)
1325 if mask.any():
1326 raise KeyError('{mask} not in index'
-> 1327 .format(mask=objarr[mask]))
1328
1329 return com._values_from_object(indexer)

KeyError: "['2011-10-03T08:22:00.000000000' '2011-10-04T11:48:00.000000000'\n '2011-10-05T10:47:00.000000000' '2011-10-05T13:15:00.000000000'\n '2011-10-06T07:21:00.000000000' '2011-10-06T10:04:00.000000000'\n '2011-10-06T12:14:00.000000000' '2011-10-06T12:49:00.000000000'\n '2011-10-06T14:52:00.000000000' '2011-10-07T07:34:00.000000000'\n '2011-10-07T08:37:00.000000000' '2011-10-07T11:09:00.000000000'\n '2011-10-07T13:14:00.000000000' '2011-10-07T15:20:00.000000000'\n '2011-10-07T16:50:00.000000000' '2011-10-09T16:53:00.000000000'\n '2011-10-10T07:29:00.000000000' '2011-10-10T10:13:00.000000000'\n '2011-10-10T13:41:00.000000000' '2011-10-10T14:02:00.000000000'\n '2011-10-10T15:23:00.000000000' '2011-10-11T14:09:00.000000000'\n '2011-10-12T08:11:00.000000000' '2011-10-12T09:57:00.000000000'\n '2011-10-12T10:06:00.000000000' '2011-10-12T12:01:00.000000000'\n '2011-10-12T12:30:00.000000000' '2011-10-12T13:56:00.000000000'\n '2011-10-13T09:10:00.000000000' '2011-10-13T10:52:00.000000000'\n '2011-10-13T11:04:00.000000000' '2011-10-13T14:41:00.000000000'\n '2011-10-13T15:06:00.000000000' '2011-10-13T15:45:00.000000000'\n '2011-10-13T15:58:00.000000000' '2011-10-14T09:02:00.000000000'\n '2011-10-14T10:02:00.000000000' '2011-10-14T14:07:00.000000000'\n '2011-10-17T09:24:00.000000000' '2011-10-17T11:19:00.000000000'\n '2011-10-17T14:05:00.000000000' '2011-10-18T09:20:00.000000000'\n '2011-10-18T09:39:00.000000000' '2011-10-18T11:32:00.000000000'\n '2011-10-18T12:54:00.000000000' '2011-10-19T09:15:00.000000000'\n '2011-10-19T09:31:00.000000000' '2011-10-19T14:08:00.000000000'\n '2011-10-19T15:11:00.000000000' '2011-10-20T13:01:00.000000000'\n '2011-10-20T15:59:00.000000000' '2011-10-21T10:39:00.000000000'\n '2011-10-21T13:15:00.000000000' '2011-10-21T15:09:00.000000000'\n '2011-10-24T09:51:00.000000000' '2011-10-24T10:15:00.000000000'\n '2011-10-24T10:21:00.000000000' '2011-10-24T14:32:00.000000000'\n '2011-10-25T07:54:00.000000000' '2011-10-25T09:37:00.000000000'\n '2011-10-25T14:30:00.000000000' '2011-10-25T17:52:00.000000000'\n '2011-10-26T09:15:00.000000000' '2011-10-26T09:42:00.000000000'\n '2011-10-26T11:59:00.000000000' '2011-10-26T13:38:00.000000000'\n '2011-10-27T08:03:00.000000000' '2011-10-27T11:14:00.000000000'\n '2011-10-27T13:51:00.000000000' '2011-10-28T13:33:00.000000000'\n '2011-10-31T10:58:00.000000000' '2011-10-31T11:00:00.000000000'\n '2011-10-31T13:58:00.000000000' '2011-10-31T14:35:00.000000000'\n '2011-11-01T08:21:00.000000000' '2011-11-01T09:33:00.000000000'\n '2011-11-01T10:13:00.000000000' '2011-11-01T15:07:00.000000000'\n '2011-11-01T15:19:00.000000000' '2011-11-02T10:56:00.000000000'\n '2011-11-03T09:52:00.000000000' '2011-11-04T10:41:00.000000000'\n '2011-11-04T13:22:00.000000000' '2011-11-08T13:32:00.000000000'\n '2011-11-08T15:08:00.000000000' '2011-11-09T12:09:00.000000000'\n '2011-11-09T13:57:00.000000000' '2011-11-10T10:26:00.000000000'\n '2011-11-10T15:36:00.000000000' '2011-11-10T15:52:00.000000000'\n '2011-11-11T10:27:00.000000000' '2011-11-11T12:19:00.000000000'\n '2011-11-11T13:29:00.000000000' '2011-11-14T10:53:00.000000000'\n '2011-11-14T19:21:00.000000000' '2011-11-15T10:32:00.000000000'\n '2011-11-15T15:04:00.000000000' '2011-11-15T16:00:00.000000000'\n '2011-11-16T09:24:00.000000000' '2011-11-16T09:58:00.000000000'\n '2011-11-16T12:57:00.000000000' '2011-11-17T11:24:00.000000000'\n '2011-11-17T13:59:00.000000000' '2011-11-18T11:15:00.000000000'\n '2011-11-18T16:05:00.000000000' '2011-11-20T14:20:00.000000000'\n '2011-11-21T09:21:00.000000000' '2011-11-21T10:06:00.000000000'\n '2011-11-21T11:34:00.000000000' '2011-11-21T11:40:00.000000000'\n '2011-11-21T14:07:00.000000000' '2011-11-23T09:33:00.000000000'\n '2011-11-23T09:45:00.000000000' '2011-11-23T12:31:00.000000000'\n '2011-11-24T11:27:00.000000000' '2011-11-24T13:33:00.000000000'\n '2011-11-24T14:13:00.000000000' '2011-11-24T15:00:00.000000000'\n '2011-11-28T09:41:00.000000000' '2011-11-30T13:20:00.000000000'\n '2011-12-01T11:12:00.000000000' '2011-12-03T17:02:00.000000000'\n '2011-12-05T14:53:00.000000000' '2011-12-06T10:36:00.000000000'\n '2011-12-06T11:29:00.000000000' '2011-12-06T13:57:00.000000000'\n '2011-12-07T10:37:00.000000000' '2011-12-07T11:33:00.000000000'\n '2011-12-07T15:02:00.000000000' '2011-12-08T13:56:00.000000000'\n '2011-12-09T10:32:00.000000000' '2011-12-09T15:47:00.000000000'\n '2011-12-09T17:29:00.000000000' '2011-12-12T09:30:00.000000000'\n '2011-12-12T13:42:00.000000000' '2011-12-13T10:08:00.000000000'\n '2011-12-13T13:32:00.000000000' '2011-12-13T13:36:00.000000000'\n '2011-12-13T15:09:00.000000000' '2011-12-19T12:09:00.000000000'\n '2012-01-11T14:42:00.000000000' '2012-01-11T17:13:00.000000000'\n '2012-01-13T10:31:00.000000000' '2012-01-13T14:59:00.000000000'\n '2012-01-16T09:58:00.000000000' '2012-01-16T11:58:00.000000000'\n '2012-01-16T13:51:00.000000000' '2012-01-16T15:28:00.000000000'\n '2012-01-18T11:14:00.000000000' '2012-01-18T14:28:00.000000000'\n '2012-01-18T18:02:00.000000000' '2012-01-20T15:11:00.000000000'\n '2012-01-21T13:48:00.000000000' '2012-01-23T11:51:00.000000000'\n '2012-01-23T13:15:00.000000000' '2012-01-24T10:29:00.000000000'\n '2012-01-25T09:44:00.000000000' '2012-01-25T10:03:00.000000000'\n '2012-01-26T10:18:00.000000000' '2012-01-26T13:02:00.000000000'\n '2012-01-27T10:33:00.000000000' '2012-01-27T11:01:00.000000000'\n '2012-01-27T14:23:00.000000000' '2012-01-28T13:35:00.000000000'\n '2012-01-30T09:02:00.000000000' '2012-01-30T10:05:00.000000000'\n '2012-01-30T13:30:00.000000000' '2012-02-01T09:21:00.000000000'\n '2012-02-01T12:31:00.000000000' '2012-02-01T13:30:00.000000000'\n '2012-02-01T16:21:00.000000000' '2012-02-02T10:10:00.000000000'\n '2012-02-02T13:36:00.000000000' '2012-02-03T12:24:00.000000000'\n '2012-02-03T15:38:00.000000000' '2012-02-04T11:48:00.000000000'\n '2012-02-04T14:55:00.000000000' '2012-02-05T13:40:00.000000000'\n '2012-02-05T15:33:00.000000000' '2012-02-06T07:45:00.000000000'\n '2012-02-06T10:55:00.000000000' '2012-02-06T11:34:00.000000000'\n '2012-02-06T12:42:00.000000000' '2012-02-06T17:50:00.000000000'\n '2012-02-08T11:17:00.000000000' '2012-02-10T07:44:00.000000000'\n '2012-02-10T12:52:00.000000000' '2012-02-10T16:32:00.000000000'\n '2012-02-11T12:35:00.000000000' '2012-02-12T13:45:00.000000000'\n '2012-02-13T16:31:00.000000000' '2012-02-17T13:38:00.000000000'\n '2012-02-19T15:29:00.000000000' '2012-02-20T12:13:00.000000000'\n '2012-02-20T17:12:00.000000000' '2012-02-21T08:49:00.000000000'\n '2012-02-22T09:54:00.000000000' '2012-02-22T13:23:00.000000000'\n '2012-02-22T16:05:00.000000000' '2012-02-22T16:08:00.000000000'\n '2012-02-23T15:57:00.000000000' '2012-02-24T13:44:00.000000000'\n '2012-02-25T16:39:00.000000000' '2012-02-27T08:42:00.000000000'\n '2012-02-27T15:35:00.000000000' '2012-02-28T11:13:00.000000000'\n '2012-02-29T09:27:00.000000000' '2012-02-29T12:57:00.000000000'\n '2012-03-01T10:07:00.000000000' '2012-03-01T14:24:00.000000000'\n '2012-03-02T15:13:00.000000000' '2012-03-04T15:07:00.000000000'\n '2012-03-06T11:13:00.000000000' '2012-03-07T12:50:00.000000000'\n '2012-03-08T12:59:00.000000000' '2012-03-09T12:45:00.000000000'\n '2012-03-12T10:17:00.000000000' '2012-03-12T12:07:00.000000000'\n '2012-03-12T17:28:00.000000000' '2012-04-04T09:48:00.000000000'\n '2012-04-04T11:12:00.000000000' '2012-04-04T13:33:00.000000000'\n '2012-04-04T17:00:00.000000000' '2012-04-04T17:02:00.000000000'\n '2012-04-05T10:39:00.000000000' '2012-04-05T11:59:00.000000000'\n '2012-04-10T09:51:00.000000000' '2012-04-10T10:45:00.000000000'\n '2012-04-10T13:55:00.000000000' '2012-04-11T11:37:00.000000000'\n '2012-04-26T16:45:00.000000000' '2012-04-26T17:59:00.000000000'\n '2012-04-27T11:03:00.000000000' '2012-04-27T13:16:00.000000000'\n '2012-04-30T08:58:00.000000000' '2012-04-30T13:15:00.000000000'\n '2012-04-30T14:54:00.000000000' '2012-05-01T14:11:00.000000000'\n '2012-05-02T12:00:00.000000000' '2012-05-02T13:25:00.000000000'\n '2012-05-03T12:14:00.000000000' '2012-05-03T13:13:00.000000000'\n '2012-05-04T11:08:00.000000000' '2012-05-07T10:17:00.000000000'\n '2012-05-07T12:56:00.000000000' '2012-05-07T13:31:00.000000000'\n '2012-05-07T18:20:00.000000000' '2012-05-08T11:34:00.000000000'\n '2012-05-08T11:47:00.000000000' '2012-05-09T12:54:00.000000000'\n '2012-05-09T14:10:00.000000000' '2012-05-09T16:55:00.000000000'\n '2012-05-10T12:12:00.000000000' '2012-05-10T15:44:00.000000000'\n '2012-05-10T17:59:00.000000000' '2012-05-11T15:40:00.000000000'\n '2012-05-12T09:50:00.000000000' '2012-05-14T10:02:00.000000000'\n '2012-05-14T12:23:00.000000000' '2012-05-14T15:27:00.000000000'\n '2012-05-15T09:07:00.000000000' '2012-05-15T09:19:00.000000000'\n '2012-05-15T13:06:00.000000000' '2012-05-15T13:42:00.000000000'\n '2012-05-16T09:17:00.000000000' '2012-05-16T10:25:00.000000000'\n '2012-05-16T13:24:00.000000000' '2012-05-16T16:05:00.000000000'\n '2012-05-16T16:57:00.000000000' '2012-05-17T09:22:00.000000000'\n '2012-05-17T13:02:00.000000000' '2012-05-17T14:25:00.000000000'\n '2012-05-17T18:48:00.000000000' '2012-05-18T09:19:00.000000000'\n '2012-05-18T12:57:00.000000000' '2012-05-18T13:14:00.000000000'\n '2012-05-20T14:00:00.000000000' '2012-05-21T09:15:00.000000000'\n '2012-05-21T14:40:00.000000000' '2012-05-22T10:08:00.000000000'\n '2012-05-22T13:23:00.000000000' '2012-05-24T09:23:00.000000000'\n '2012-05-24T13:23:00.000000000' '2012-05-24T15:51:00.000000000'\n '2012-05-25T09:19:00.000000000' '2012-05-25T11:10:00.000000000'\n '2012-05-25T11:55:00.000000000' '2012-05-25T12:34:00.000000000'\n '2012-05-26T15:40:00.000000000' '2012-05-28T09:16:00.000000000'\n '2012-05-28T12:57:00.000000000' '2012-05-28T19:24:00.000000000'\n '2012-05-29T11:07:00.000000000' '2012-05-29T13:29:00.000000000'\n '2012-05-31T09:09:00.000000000' '2012-05-31T12:41:00.000000000'\n '2012-05-31T17:24:00.000000000' '2012-06-01T09:20:00.000000000'\n '2012-06-01T13:27:00.000000000' '2012-06-01T18:50:00.000000000'\n '2012-06-04T08:42:00.000000000' '2012-06-04T12:24:00.000000000'\n '2012-06-04T13:25:00.000000000' '2012-06-04T15:09:00.000000000'\n '2012-06-05T15:29:00.000000000' '2012-06-05T16:56:00.000000000'\n '2012-06-06T09:18:00.000000000' '2012-06-06T10:20:00.000000000'\n '2012-06-06T13:33:00.000000000' '2012-06-06T15:42:00.000000000'\n '2012-06-07T08:44:00.000000000' '2012-06-07T09:30:00.000000000'\n '2012-06-07T13:36:00.000000000' '2012-06-07T17:32:00.000000000'\n '2012-06-07T19:11:00.000000000' '2012-06-08T09:53:00.000000000'\n '2012-06-08T10:04:00.000000000' '2012-06-08T11:55:00.000000000'\n '2012-06-11T09:13:00.000000000' '2012-06-11T12:41:00.000000000'\n '2012-06-11T13:25:00.000000000' '2012-06-11T14:59:00.000000000'\n '2012-06-11T16:01:00.000000000' '2012-06-11T19:08:00.000000000'\n '2012-06-12T08:15:00.000000000' '2012-06-15T12:40:00.000000000'\n '2012-06-15T12:43:00.000000000' '2012-06-17T13:43:00.000000000'\n '2012-06-17T17:44:00.000000000' '2012-06-18T09:12:00.000000000'\n '2012-06-18T13:02:00.000000000' '2012-06-18T17:55:00.000000000'\n '2012-06-19T11:28:00.000000000' '2012-06-20T12:49:00.000000000'\n '2012-06-26T11:18:00.000000000' '2012-06-26T15:05:00.000000000'\n '2012-06-26T19:35:00.000000000' '2012-06-27T12:06:00.000000000'\n '2012-06-28T11:46:00.000000000' '2012-06-28T17:42:00.000000000'\n '2012-06-29T09:17:00.000000000' '2012-06-29T16:47:00.000000000'\n '2012-07-02T12:12:00.000000000' '2012-07-02T17:09:00.000000000'\n '2012-07-03T12:17:00.000000000' '2012-07-03T16:09:00.000000000'\n '2012-07-04T09:58:00.000000000' '2012-07-04T12:49:00.000000000'\n '2012-07-04T13:42:00.000000000' '2012-07-05T09:16:00.000000000'\n '2012-07-05T12:08:00.000000000' '2012-07-05T16:12:00.000000000'\n '2012-07-06T13:24:00.000000000' '2012-07-06T18:03:00.000000000'\n '2012-07-07T17:12:00.000000000' '2012-07-08T12:03:00.000000000'\n '2012-07-09T09:20:00.000000000' '2012-07-09T12:15:00.000000000'\n '2012-07-09T14:20:00.000000000' '2012-07-10T09:12:00.000000000'\n '2012-07-10T13:36:00.000000000' '2012-07-11T09:11:00.000000000'\n '2012-07-12T09:21:00.000000000' '2012-07-13T09:19:00.000000000'\n '2012-07-16T12:53:00.000000000' '2012-07-16T16:57:00.000000000'\n '2012-07-17T09:16:00.000000000' '2012-07-20T09:20:00.000000000'\n '2012-07-25T09:16:00.000000000' '2012-07-25T10:39:00.000000000'\n '2012-07-25T10:54:00.000000000' '2012-07-25T14:32:00.000000000'\n '2012-07-26T09:58:00.000000000' '2012-07-26T11:39:00.000000000'\n '2012-07-26T13:38:00.000000000' '2012-07-27T09:16:00.000000000'\n '2012-07-27T11:16:00.000000000' '2012-07-28T20:08:00.000000000'\n '2012-07-30T11:15:00.000000000' '2012-07-30T13:35:00.000000000'\n '2012-07-30T16:10:00.000000000' '2012-07-31T13:26:00.000000000'\n '2012-08-01T13:13:00.000000000' '2012-08-01T14:23:00.000000000'\n '2012-08-02T09:16:00.000000000' '2012-08-02T13:18:00.000000000'\n '2012-08-02T15:46:00.000000000' '2012-08-05T16:35:00.000000000'\n '2012-08-06T11:08:00.000000000' '2012-08-06T11:20:00.000000000'\n '2012-08-06T13:18:00.000000000' '2012-08-06T13:37:00.000000000'\n '2012-08-07T10:38:00.000000000' '2012-08-07T13:02:00.000000000'\n '2012-08-08T09:28:00.000000000' '2012-08-08T12:26:00.000000000'\n '2012-08-08T13:19:00.000000000' '2012-08-08T13:34:00.000000000'\n '2012-08-08T15:49:00.000000000' '2012-08-09T10:44:00.000000000'\n '2012-08-09T11:40:00.000000000' '2012-08-09T13:10:00.000000000'\n '2012-08-09T13:25:00.000000000' '2012-08-09T15:10:00.000000000'\n '2012-08-13T09:36:00.000000000' '2012-08-13T13:46:00.000000000'\n '2012-08-14T09:23:00.000000000' '2012-08-14T10:46:00.000000000'\n '2012-08-14T14:23:00.000000000' '2012-08-14T19:05:00.000000000'\n '2012-08-15T09:27:00.000000000' '2012-08-15T14:16:00.000000000'\n '2012-08-16T09:16:00.000000000' '2012-08-16T15:42:00.000000000'\n '2012-08-17T09:26:00.000000000' '2012-08-17T13:15:00.000000000'\n '2012-08-20T09:28:00.000000000' '2012-08-20T14:10:00.000000000'\n '2012-08-21T10:06:00.000000000' '2012-08-21T13:01:00.000000000'\n '2012-08-21T16:05:00.000000000' '2012-08-22T09:57:00.000000000'\n '2012-08-22T13:52:00.000000000' '2012-08-23T09:17:00.000000000'\n '2012-08-23T13:00:00.000000000' '2012-08-23T13:16:00.000000000'\n '2012-08-24T15:32:00.000000000' '2012-08-25T15:11:00.000000000'\n '2012-08-27T09:55:00.000000000' '2012-08-27T13:53:00.000000000'\n '2012-08-28T10:48:00.000000000' '2012-08-29T13:34:00.000000000'\n '2012-08-30T09:33:00.000000000' '2012-08-30T13:38:00.000000000'\n '2012-08-30T17:36:00.000000000' '2012-08-31T09:24:00.000000000'\n '2012-08-31T11:21:00.000000000' '2012-08-31T13:53:00.000000000'\n '2012-08-31T15:20:00.000000000' '2012-09-01T14:13:00.000000000'\n '2012-09-01T17:43:00.000000000' '2012-09-03T12:19:00.000000000'\n '2012-09-03T16:15:00.000000000' '2012-09-04T11:43:00.000000000'\n '2012-09-04T14:52:00.000000000' '2012-09-05T09:28:00.000000000'\n '2012-09-05T14:06:00.000000000' '2012-09-05T14:48:00.000000000'\n '2012-09-06T13:15:00.000000000' '2012-09-07T09:20:00.000000000'\n '2012-09-07T09:49:00.000000000' '2012-09-07T13:40:00.000000000'\n '2012-09-07T16:53:00.000000000' '2012-09-10T09:30:00.000000000'\n '2012-09-10T13:30:00.000000000' '2012-09-10T17:21:00.000000000'\n '2012-09-11T13:11:00.000000000' '2012-09-12T17:05:00.000000000'\n '2012-09-13T11:07:00.000000000' '2012-09-13T13:15:00.000000000'\n '2012-09-13T14:51:00.000000000' '2012-09-14T07:38:00.000000000'\n '2012-09-14T11:35:00.000000000' '2012-09-15T13:28:00.000000000'\n '2012-09-15T18:53:00.000000000' '2012-09-17T09:37:00.000000000'\n '2012-09-17T13:09:00.000000000' '2012-09-18T10:22:00.000000000'\n '2012-09-19T14:48:00.000000000' '2012-09-20T09:45:00.000000000'\n '2012-09-20T13:04:00.000000000' '2012-09-21T11:51:00.000000000'\n '2012-09-21T12:56:00.000000000' '2012-09-24T13:13:00.000000000'\n '2012-09-24T13:39:00.000000000' '2012-09-24T15:21:00.000000000'\n '2012-09-25T11:10:00.000000000' '2012-09-25T15:38:00.000000000'\n '2012-09-26T09:28:00.000000000' '2012-09-26T12:36:00.000000000'\n '2012-09-26T16:02:00.000000000' '2012-09-27T10:00:00.000000000'\n '2012-09-27T11:50:00.000000000' '2012-09-27T13:32:00.000000000'\n '2012-09-28T09:22:00.000000000' '2012-09-28T10:20:00.000000000'\n '2012-09-28T13:17:00.000000000' '2012-09-29T09:05:00.000000000'\n '2012-09-29T15:16:00.000000000' '2012-10-01T09:23:00.000000000'\n '2012-10-01T09:58:00.000000000' '2012-10-01T12:11:00.000000000'\n '2012-10-01T13:08:00.000000000' '2012-10-03T17:06:00.000000000'\n '2012-10-04T08:20:00.000000000' '2012-10-04T10:40:00.000000000'\n '2012-10-04T12:43:00.000000000' '2012-10-04T14:33:00.000000000'\n '2012-10-05T08:22:00.000000000' '2012-10-05T12:47:00.000000000'\n '2012-10-05T13:02:00.000000000' '2012-10-05T15:10:00.000000000'\n '2012-10-05T17:40:00.000000000' '2012-10-08T13:29:00.000000000'\n '2012-10-08T13:48:00.000000000' '2012-10-08T15:03:00.000000000'\n '2012-10-09T09:44:00.000000000' '2012-10-09T11:16:00.000000000'\n '2012-10-09T12:25:00.000000000' '2012-10-10T10:03:00.000000000'\n '2012-10-10T11:03:00.000000000' '2012-10-10T11:53:00.000000000'\n '2012-10-10T13:10:00.000000000' '2012-10-10T13:45:00.000000000'\n '2012-10-10T15:50:00.000000000' '2012-10-11T10:18:00.000000000'\n '2012-10-11T12:58:00.000000000' '2012-10-12T09:47:00.000000000'\n '2012-10-12T10:50:00.000000000' '2012-10-12T13:34:00.000000000'\n '2012-10-13T12:37:00.000000000' '2012-10-13T15:32:00.000000000'\n '2012-10-14T16:44:00.000000000' '2012-10-15T08:44:00.000000000'\n '2012-10-15T10:35:00.000000000' '2012-10-15T13:24:00.000000000'\n '2012-10-15T14:57:00.000000000' '2012-10-16T12:37:00.000000000'\n '2012-10-17T09:50:00.000000000' '2012-10-17T10:25:00.000000000'\n '2012-10-17T13:00:00.000000000' '2012-10-17T13:01:00.000000000'\n '2012-10-17T13:50:00.000000000' '2012-10-18T09:44:00.000000000'\n '2012-10-18T10:04:00.000000000' '2012-10-18T11:40:00.000000000'\n '2012-10-18T13:41:00.000000000' '2012-10-19T10:20:00.000000000'\n '2012-10-19T16:18:00.000000000' '2012-10-20T14:20:00.000000000'\n '2012-10-20T16:35:00.000000000' '2012-10-20T16:36:00.000000000'\n '2012-10-22T10:46:00.000000000' '2012-10-22T12:08:00.000000000'\n '2012-10-22T13:28:00.000000000' '2012-10-22T16:39:00.000000000'\n '2012-10-23T12:43:00.000000000' '2012-10-25T09:55:00.000000000'\n '2012-10-26T16:03:00.000000000' '2012-10-30T09:36:00.000000000'\n '2012-10-31T12:51:00.000000000' '2012-10-31T14:11:00.000000000'\n '2012-10-31T18:02:00.000000000' '2012-11-01T11:19:00.000000000'\n '2012-11-01T15:20:00.000000000' '2012-11-02T11:38:00.000000000'\n '2012-11-02T13:46:00.000000000' '2012-11-05T11:17:00.000000000'\n '2012-11-05T13:25:00.000000000' '2012-11-06T09:30:00.000000000'\n '2012-11-07T09:53:00.000000000' '2012-11-07T10:59:00.000000000'\n '2012-11-07T12:45:00.000000000' '2012-11-08T11:38:00.000000000'\n '2012-11-08T13:50:00.000000000' '2012-11-09T10:07:00.000000000'\n '2012-11-09T10:26:00.000000000' '2012-11-09T12:11:00.000000000'\n '2012-11-09T12:48:00.000000000' '2012-11-09T13:14:00.000000000'\n '2012-11-12T09:34:00.000000000' '2012-11-12T09:36:00.000000000'\n '2012-11-12T13:21:00.000000000' '2012-11-14T12:50:00.000000000'\n '2012-11-15T14:38:00.000000000' '2012-11-16T10:22:00.000000000'\n '2012-11-16T13:45:00.000000000' '2012-11-19T11:27:00.000000000'\n '2012-11-19T13:18:00.000000000' '2012-11-19T16:27:00.000000000'\n '2012-11-20T10:49:00.000000000' '2012-11-20T12:15:00.000000000'\n '2012-11-20T13:44:00.000000000' '2012-11-21T09:58:00.000000000'\n '2012-11-21T16:27:00.000000000' '2012-11-23T11:38:00.000000000'\n '2012-11-23T12:45:00.000000000' '2012-11-23T13:22:00.000000000'\n '2012-11-23T13:52:00.000000000' '2012-11-24T11:44:00.000000000'\n '2012-11-24T12:49:00.000000000' '2012-11-26T10:00:00.000000000'\n '2012-11-26T10:50:00.000000000' '2012-11-26T13:34:00.000000000'\n '2012-11-28T09:58:00.000000000' '2012-11-28T12:58:00.000000000'\n '2012-11-30T16:07:00.000000000' '2012-12-03T11:21:00.000000000'\n '2012-12-03T17:00:00.000000000' '2012-12-04T10:47:00.000000000'\n '2012-12-04T13:03:00.000000000' '2012-12-04T14:08:00.000000000'\n '2012-12-05T11:13:00.000000000' '2012-12-06T14:36:00.000000000'\n '2012-12-07T11:22:00.000000000' '2012-12-08T12:29:00.000000000'\n '2012-12-08T14:20:00.000000000' '2012-12-08T17:15:00.000000000'\n '2012-12-10T12:12:00.000000000' '2012-12-11T10:29:00.000000000'\n '2012-12-11T14:23:00.000000000' '2012-12-12T09:43:00.000000000'\n '2012-12-12T13:07:00.000000000' '2012-12-12T15:17:00.000000000'\n '2012-12-14T10:24:00.000000000' '2012-12-17T14:36:00.000000000'\n '2012-12-18T11:04:00.000000000' '2012-12-18T13:50:00.000000000'\n '2012-12-21T15:23:00.000000000' '2013-01-08T13:58:00.000000000'\n '2013-01-09T15:25:00.000000000' '2013-01-10T11:05:00.000000000'\n '2013-01-11T10:57:00.000000000' '2013-01-11T13:36:00.000000000'\n '2013-01-11T17:06:00.000000000' '2013-01-15T08:25:00.000000000'\n '2013-01-16T12:38:00.000000000' '2013-01-16T18:09:00.000000000'\n '2013-01-17T13:45:00.000000000' '2013-01-21T14:07:00.000000000'\n '2013-01-28T14:01:00.000000000' '2013-01-29T13:43:00.000000000'\n '2013-01-29T15:06:00.000000000' '2013-02-04T13:25:00.000000000'\n '2013-02-06T17:33:00.000000000' '2013-02-07T13:30:00.000000000'\n '2013-02-12T08:36:00.000000000' '2013-02-12T11:39:00.000000000'\n '2013-02-13T13:58:00.000000000' '2013-02-16T11:55:00.000000000'\n '2013-02-18T13:46:00.000000000' '2013-02-21T13:44:00.000000000'\n '2013-02-21T15:02:00.000000000' '2013-02-25T13:33:00.000000000'\n '2013-02-25T17:25:00.000000000' '2013-02-27T09:33:00.000000000'] not in index"

data.plot gives a ValueError

Hey Quentin.

After having seen your great talk at PyData in Seattle, I tried to analyse your coffees.csv dataset by myself using a blank notebook. Everything worked out fine until I tried to plot the data. When using

data.coffees.plot()

I get that plot with the spike at the end. But when trying to plot against the datetime with

data.plot(x=data.timestamp, style=".-")

I receive a ValueError.
I now checked my code with your solutions notebook and it's pretty identical, so I went ahead and "Restart & Run all" your solutions notebook. Now this code gives the same error in your notebook.

Have you any idea why this happens? I find the error message quite cryptic.

I'm running matplotlib-2.1.2, python-dateutil-2.6.1 and pandas-0.22.0.


Error Message

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-20-10c3ef6629e6> in <module>()
      1 # .plot() on the dataframe, setting x to the timestamp, with dot-dash style
----> 2 data.plot(x=data.timestamp, style=".-")

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/plotting/_core.py in __call__(self, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   2675                           fontsize=fontsize, colormap=colormap, table=table,
   2676                           yerr=yerr, xerr=xerr, secondary_y=secondary_y,
-> 2677                           sort_columns=sort_columns, **kwds)
   2678     __call__.__doc__ = plot_frame.__doc__
   2679 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/plotting/_core.py in plot_frame(data, x, y, kind, ax, subplots, sharex, sharey, layout, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, secondary_y, sort_columns, **kwds)
   1900                  yerr=yerr, xerr=xerr,
   1901                  secondary_y=secondary_y, sort_columns=sort_columns,
-> 1902                  **kwds)
   1903 
   1904 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
   1727         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   1728 
-> 1729     plot_obj.generate()
   1730     plot_obj.draw()
   1731     return plot_obj.result

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/plotting/_core.py in generate(self)
    256 
    257         for ax in self.axes:
--> 258             self._post_plot_logic_common(ax, self.data)
    259             self._post_plot_logic(ax, self.data)
    260 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/plotting/_core.py in _post_plot_logic_common(self, ax, data)
    395             self._apply_axis_properties(ax.xaxis, rot=self.rot,
    396                                         fontsize=self.fontsize)
--> 397             self._apply_axis_properties(ax.yaxis, fontsize=self.fontsize)
    398 
    399             if hasattr(ax, 'right_ax'):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/plotting/_core.py in _apply_axis_properties(self, axis, rot, fontsize)
    468 
    469     def _apply_axis_properties(self, axis, rot=None, fontsize=None):
--> 470         labels = axis.get_majorticklabels() + axis.get_minorticklabels()
    471         for label in labels:
    472             if rot is not None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py in get_majorticklabels(self)
   1186     def get_majorticklabels(self):
   1187         'Return a list of Text instances for the major ticklabels'
-> 1188         ticks = self.get_major_ticks()
   1189         labels1 = [tick.label1 for tick in ticks if tick.label1On]
   1190         labels2 = [tick.label2 for tick in ticks if tick.label2On]

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py in get_major_ticks(self, numticks)
   1337         'get the tick instances; grow as necessary'
   1338         if numticks is None:
-> 1339             numticks = len(self.get_major_locator()())
   1340         if len(self.majorTicks) < numticks:
   1341             # update the new tick label properties from the old

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in __call__(self)
   1095     def __call__(self):
   1096         'Return the locations of the ticks'
-> 1097         self.refresh()
   1098         return self._locator()
   1099 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in refresh(self)
   1115     def refresh(self):
   1116         'Refresh internal information based on current limits.'
-> 1117         dmin, dmax = self.viewlim_to_dt()
   1118         self._locator = self.get_locator(dmin, dmax)
   1119 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in viewlim_to_dt(self)
    873             vmin, vmax = vmax, vmin
    874 
--> 875         return num2date(vmin, self.tz), num2date(vmax, self.tz)
    876 
    877     def _get_unit(self):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in num2date(x, tz)
    464         tz = _get_rc_timezone()
    465     if not cbook.iterable(x):
--> 466         return _from_ordinalf(x, tz)
    467     else:
    468         x = np.asarray(x)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in _from_ordinalf(x, tz)
    277 
    278     ix = int(x)
--> 279     dt = datetime.datetime.fromordinal(ix).replace(tzinfo=UTC)
    280 
    281     remainder = float(x) - ix

ValueError: ordinal must be >= 1

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
    339                 pass
    340             else:
--> 341                 return printer(obj)
    342             # Finally look for special method names
    343             method = get_real_method(obj, self.print_method)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/pylabtools.py in <lambda>(fig)
    236 
    237     if 'png' in formats:
--> 238         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    239     if 'retina' in formats or 'png2x' in formats:
    240         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
    120 
    121     bytes_io = BytesIO()
--> 122     fig.canvas.print_figure(bytes_io, **kw)
    123     data = bytes_io.getvalue()
    124     if fmt == 'svg':

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2214                     orientation=orientation,
   2215                     dryrun=True,
-> 2216                     **kwargs)
   2217                 renderer = self.figure._cachedRenderer
   2218                 bbox_inches = self.figure.get_tightbbox(renderer)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
    505 
    506     def print_png(self, filename_or_obj, *args, **kwargs):
--> 507         FigureCanvasAgg.draw(self)
    508         renderer = self.get_renderer()
    509         original_dpi = renderer.dpi

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw(self)
    428             # if toolbar:
    429             #     toolbar.set_cursor(cursors.WAIT)
--> 430             self.figure.draw(self.renderer)
    431         finally:
    432             # if toolbar:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/figure.py in draw(self, renderer)
   1297 
   1298             mimage._draw_list_compositing_images(
-> 1299                 renderer, self, artists, self.suppressComposite)
   1300 
   1301             renderer.close_group('figure')

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    136     if not_composite or not has_images:
    137         for a in artists:
--> 138             a.draw(renderer)
    139     else:
    140         # Composite any adjacent images together

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe)
   2435             renderer.stop_rasterizing()
   2436 
-> 2437         mimage._draw_list_compositing_images(renderer, self, artists)
   2438 
   2439         renderer.close_group('axes')

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    136     if not_composite or not has_images:
    137         for a in artists:
--> 138             a.draw(renderer)
    139     else:
    140         # Composite any adjacent images together

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     53                 renderer.start_filter()
     54 
---> 55             return draw(artist, renderer, *args, **kwargs)
     56         finally:
     57             if artist.get_agg_filter() is not None:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)
   1131         renderer.open_group(__name__)
   1132 
-> 1133         ticks_to_draw = self._update_ticks(renderer)
   1134         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
   1135                                                                 renderer)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py in _update_ticks(self, renderer)
    972 
    973         interval = self.get_view_interval()
--> 974         tick_tups = list(self.iter_ticks())
    975         if self._smart_bounds and tick_tups:
    976             # handle inverted limits

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/axis.py in iter_ticks(self)
    915         Iterate through all of the major and minor ticks.
    916         """
--> 917         majorLocs = self.major.locator()
    918         majorTicks = self.get_major_ticks(len(majorLocs))
    919         self.major.formatter.set_locs(majorLocs)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in __call__(self)
   1095     def __call__(self):
   1096         'Return the locations of the ticks'
-> 1097         self.refresh()
   1098         return self._locator()
   1099 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in refresh(self)
   1115     def refresh(self):
   1116         'Refresh internal information based on current limits.'
-> 1117         dmin, dmax = self.viewlim_to_dt()
   1118         self._locator = self.get_locator(dmin, dmax)
   1119 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in viewlim_to_dt(self)
    873             vmin, vmax = vmax, vmin
    874 
--> 875         return num2date(vmin, self.tz), num2date(vmax, self.tz)
    876 
    877     def _get_unit(self):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in num2date(x, tz)
    464         tz = _get_rc_timezone()
    465     if not cbook.iterable(x):
--> 466         return _from_ordinalf(x, tz)
    467     else:
    468         x = np.asarray(x)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib/dates.py in _from_ordinalf(x, tz)
    277 
    278     ix = int(x)
--> 279     dt = datetime.datetime.fromordinal(ix).replace(tzinfo=UTC)
    280 
    281     remainder = float(x) - ix

ValueError: ordinal must be >= 1

<matplotlib.figure.Figure at 0x1114ab5f8>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.