Comments (7)
Hi, Thank you for sharing the code, when I ran the code, I got the flowing error message, please help me to solve this problem:
Traceback (most recent call last): File "/content/LyDROO/LyDROOwithTF2conv.py", line 183, in plot_rate(Q, 100, 'Data Queue of WDs') File "/content/LyDROO/LyDROOwithTF2conv.py", line 39, in plot_rate plt.plot(np.arange(len(rate_array))+1, df.rolling(rolling_intv, min_periods=1).mean()) File "/usr/local/lib/python3.7/dist-packages/matplotlib/pyplot.py", line 2763, in plot is not None else {}), **kwargs) File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_axes.py", line 1647, in plot lines = [*self._get_lines(*args, data=data, **kwargs)] File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 216, in call yield from self._plot_args(this, kwargs) File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 332, in _plot_args y = _check_1d(tup[-1]) File "/usr/local/lib/python3.7/dist-packages/matplotlib/cbook/init.py", line 1349, in _check_1d ndim = x[:, None].ndim File "/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py", line 2906, in getitem indexer = self.columns.get_loc(key) File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/range.py", line 358, in get_loc raise KeyError(key) KeyError: (slice(None, None, None), None)
Seems that the values of Q are empty when you run the plot_rate code on line 183.
You may execute the 'save all data' first to check the values by move lines 189-190 before line 183. All data will be saved in a .mat file for your debug.
from lydroo.
Hi, Thank you for sharing the code, when I ran the code, I got the flowing error message, please help me to solve this problem:
Traceback (most recent call last): File "/content/LyDROO/LyDROOwithTF2conv.py", line 183, in plot_rate(Q, 100, 'Data Queue of WDs') File "/content/LyDROO/LyDROOwithTF2conv.py", line 39, in plot_rate plt.plot(np.arange(len(rate_array))+1, df.rolling(rolling_intv, min_periods=1).mean()) File "/usr/local/lib/python3.7/dist-packages/matplotlib/pyplot.py", line 2763, in plot is not None else {}), **kwargs) File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_axes.py", line 1647, in plot lines = [*self._get_lines(*args, data=data, **kwargs)] File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 216, in call yield from self._plot_args(this, kwargs) File "/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py", line 332, in _plot_args y = _check_1d(tup[-1]) File "/usr/local/lib/python3.7/dist-packages/matplotlib/cbook/init.py", line 1349, in _check_1d ndim = x[:, None].ndim File "/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py", line 2906, in getitem indexer = self.columns.get_loc(key) File "/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/range.py", line 358, in get_loc raise KeyError(key) KeyError: (slice(None, None, None), None)Seems that the values of Q are empty when you run the plot_rate code on line 183. You may execute the 'save all data' first to check the values by move lines 189-190 before line 183. All data will be saved in a .mat file for your debug.
Thank you for your advice; I followed your instructions, but the problem persists.
from lydroo.
Thank you for your advice; I followed your instructions, but the problem persists. Do you have another suggestion for solving the problem?
from lydroo.
from lydroo.
The 'data_queue' key in the .mat file is a NumPy.ndarray which has the correct values and is not empty. Can I draw the chart separately and independently?
from lydroo.
The problem seems to be from this line:
plt.plot(np.arange(len(rate_array))+1, df.rolling(rolling_intv, min_periods=1).mean())
I changed it to:
plt.plot(np.arange(len(rate_array))+1, df.rolling(rolling_intv, min_periods=1).mean()[0])
and I think the problem was solved!
The following error may help:
in plot_rate(rate_his, rolling_intv, ylabel)
14 fig, ax = plt.subplots(figsize=(15,8))
15
---> 16 plt.plot(np.arange(len(rate_array))+1, df.rolling(rolling_intv, min_periods=1).mean())
17 plt.fill_between(np.arange(len(rate_array))+1, df.rolling(rolling_intv, min_periods=1).min()[0], df.rolling(rolling_intv, min_periods=1).max()[0], alpha = 0.2)
18 plt.ylabel(ylabel)
/usr/local/lib/python3.7/dist-packages/matplotlib/pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2761 return gca().plot(
2762 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2763 is not None else {}), **kwargs)
2764
2765
/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1645 """
1646 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D)
-> 1647 lines = [*self._get_lines(*args, data=data, **kwargs)]
1648 for line in lines:
1649 self.add_line(line)
/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py in call(self, *args, **kwargs)
214 this += args[0],
215 args = args[1:]
--> 216 yield from self._plot_args(this, kwargs)
217
218 def get_next_color(self):
/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
330 if len(tup) == 2:
331 x = _check_1d(tup[0])
--> 332 y = _check_1d(tup[-1])
333 else:
334 x, y = index_of(tup[-1])
/usr/local/lib/python3.7/dist-packages/matplotlib/cbook/init.py in _check_1d(x)
1347 message='Support for multi-dimensional indexing')
1348
-> 1349 ndim = x[:, None].ndim
1350 # we have definitely hit a pandas index or series object
1351 # cast to a numpy array.
/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py in getitem(self, key)
2904 if self.columns.nlevels > 1:
2905 return self._getitem_multilevel(key)
-> 2906 indexer = self.columns.get_loc(key)
2907 if is_integer(indexer):
2908 indexer = [indexer]
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/range.py in get_loc(self, key, method, tolerance)
356 except ValueError as err:
357 raise KeyError(key) from err
--> 358 raise KeyError(key)
359 return super().get_loc(key, method=method, tolerance=tolerance)
from lydroo.
from lydroo.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lydroo.