AssertionError: <class 'numpy.ndarray'>

0 votes

from matplotlib import style


fig = plt.figure()

ax1= fig.add_subplot(311)
ax2= fig.add_subplot(312)
ax3= fig.add_subplot(313)


style.use('ggplot')

y_2004 = dataset["2004"]["AEP_MW"].to_list()
x_2004 = dataset["2004"]["Date"].to_list()
ax1.plot(x_2004,y_2004, color="green", linewidth=1.7)


y_2005 = dataset["2005"]["AEP_MW"].to_list()
x_2005 = dataset["2005"]["Date"].to_list()
ax2.plot(x_2005, y_2005, color="green", linewidth=1)


y_2006 = dataset["2006"]["AEP_MW"].to_list()
x_2006 = dataset["2006"]["Date"].to_list()
ax3.plot(x_2006, y_2006, color="green", linewidth=1)


plt.rcParams["figure.figsize"] = (18,8)
plt.title("Energy consumptionnin")
plt.xlabel("Date")
plt.ylabel("Energy in MW")
plt.grid(True, alpha=1)
plt.legend()

for label in ax1.xaxis.get_ticklabels():
    label.set_rotation(90)

i am getting this error

AssertionError                            Traceback (most recent call last)
<ipython-input-37-0608ff1e5b3b> in <module>
     11 style.use('ggplot')
     12 
---> 13 y_2004 = dataset["2004"]["AEP_MW"].to_list()
     14 x_2004 = dataset["2004"]["Date"].to_list()
     15 ax1.plot(x_2004,y_2004, color="green", linewidth=1.7)

~\Anaconda3\lib\site-packages\pandas\core\frame.py in __getitem__(self, key)
   2883             # either we have a slice or we have a string that can be converted
   2884             #  to a slice for partial-string date indexing
-> 2885             return self._slice(indexer, axis=0)
   2886 
   2887         # Do we have a (boolean) DataFrame?

~\Anaconda3\lib\site-packages\pandas\core\generic.py in _slice(self, slobj, axis)
   3555         Slicing with this method is *always* positional.
   3556         """
-> 3557         assert isinstance(slobj, slice), type(slobj)
   3558         axis = self._get_block_manager_axis(axis)
   3559         result = self._constructor(self._mgr.get_slice(slobj, axis=axis))

AssertionError: <class 'numpy.ndarray'>
Oct 19 in Python by anonymous
• 140 points
158 views

1 answer to this question.

0 votes

Hi, @There,

The traceback module and sys.exc_info are overkill for tracking down the source of an exception. That's all in the default traceback. So instead of calling exit(1) just re-raise:

answered Oct 19 by anonymous
• 48,320 points

Related Questions In Python

0 votes
1 answer

AttributeError: type object 'numpy.ndarray' has no attribute '__array_function__'

Hi@akhtar, I think numpy version is not compatible ...READ MORE

answered Apr 13 in Python by MD
• 77,580 points
2,366 views
0 votes
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi@akhtar, If you trying to append data in ...READ MORE

answered May 5 in Python by MD
• 77,580 points
15,652 views
+1 vote
1 answer

'numpy.ndarray' object has no attribute 'append'

Hi@Noman, You created two empty list. And in ...READ MORE

answered May 17 in Python by MD
• 77,580 points
3,642 views
+1 vote
1 answer
0 votes
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi@Nilesh, You created two empty lists. And in ...READ MORE

answered Aug 10 in Python by MD
• 77,580 points
326 views
0 votes
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi@Nilesh, You have created two empty lists. And ...READ MORE

answered Aug 10 in Python by MD
• 77,580 points
1,110 views
0 votes
0 answers

Python | Combine two bots into one

Hi everyone, Basically i made a bot in ...READ MORE

Jun 30 in Python by PrKit
• 120 points
62 views
0 votes
1 answer

CamStudio is Safe or not?

Hi, If you find some negativity with the ...READ MORE

answered Nov 11 in Ask us Anything! by MD
• 77,580 points
11 views
0 votes
1 answer

How to create an empty NumPy array?

Hey, @Roshni, To create an empty array with ...READ MORE

answered Jun 23 in Python by Gitika
• 48,320 points
1,130 views
0 votes
2 answers

module 'numpy' has no attribute 'unit8'

Hi@Ganesh, I think you are calling the wrong ...READ MORE

answered Sep 22 in Python by MD
• 77,580 points
213 views