0
$\begingroup$
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plotdata = pd.DataFrame({
    "Attack 0":[57,67,77,83],    
    "Attack 1":[68,73,80,79],    
    "Attack 2":[73,78,80,85],
    "Attack 3":[73,78,80,85],    
    "Attack 4":[73,78,80,85]},    
    index=["Attack 0", "Attack 1", "Attack 2", "Attack 3", "Attack 4"])

plotdata.plot(kind="bar",figsize=(15, 8))
plt.xlabel("Different Malware Assaults")    
plt.ylabel("Accuracy")

The error that I'm getting is ValueError: Shape of passed values is (4, 4), indices imply (5, 4).

$\endgroup$
1
  • $\begingroup$ If you want index as written in your example than input data has to be changed from dictionary to a list like [[57,67,77,83], ... [73,78,80,85]]. $\endgroup$ Commented Apr 4, 2022 at 7:33

1 Answer 1

0
$\begingroup$

I guess "Attack 0", "Attack 1", ... are the labels of the columns, not the rows.

So you have to use the keyword columns=["Attack 0", "Attack 1, ..." instead of index=["Attack 0", "Attack 1, ..." when you construct your DataFrame.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.