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, 2020 in Python by anonymous
• 140 points
1,932 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, 2020 by anonymous
• 65,770 points

Related Questions In Python

0 votes
1 answer

AssertionError: <class 'numpy.ndarray'>

Same problem here bro! READ MORE

answered Dec 8, 2020 in Python by Bijoy
4,480 views
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, 2020 in Python by MD
• 95,460 points
14,749 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, 2020 in Python by MD
• 95,460 points
8,192 views
+1 vote
1 answer

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

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

answered May 17, 2020 in Python by MD
• 95,460 points
5,517 views
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 11, 2020 in Python by MD
• 95,460 points
3,274 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 11, 2020 in Python by MD
• 95,460 points
6,403 views
0 votes
0 answers

Python | Combine two bots into one

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

Jun 30, 2020 in Python by PrKit
• 120 points
753 views
0 votes
1 answer

CamStudio is Safe or not?

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

answered Nov 11, 2020 in Ask us Anything! by MD
• 95,460 points
678 views
0 votes
3 answers

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

for root, dirs, files in os.walk(directory): ...READ MORE

answered Dec 12, 2020 in Python by Rajiv
• 8,870 points
52,945 views
0 votes
4 answers

How to print objects of class using print function in Python?

>>> class Test: ... ...READ MORE

answered Dec 16, 2020 in Python by Roshni
• 10,480 points
78,555 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP