I am currently figuring out how to use pandas and matplotlib with R. I did a reconstruction of instructions given on how to plot a bar with some given csv data. All calculations work perfectly. Plotting the bar gives me an error:
TypeError: Series.plot() should not be called with positional arguments, only keyword arguments. The order of positional arguments will change in the future. Use Series.plot(kind='bar') instead of Series.plot('bar',).
This command is given to us:
train_data['Pclass'].value_counts(sort=False).plot('bar') plt.grid()
But what it it returns is:
SyntaxError: invalid syntax (<string>, line 1)
So I tried to seperate plt.grid(), but get the error mentioned:
TypeError: `Series.plot()` should not be called with positional arguments, only keyword arguments.
The order of positional arguments will change in the future.
Use `Series.plot(kind='bar')` instead of `Series.plot('bar',)`.
Step-by-step, what I did:
#Import Module Pandas
import pandas as WORKS
import matplotlib as plt WORKS
#Load the Dataset
train_data = pd.read_csv("train.csv") WORKS
train_data = train_data.set_index("Name") WORKS
#Print the Data-Head
print(train_data.head(31)) WORKS
# get the shape of the data set
train_data.shape WORKS
# get the data types
train_data.dtypes WORKS
# get the first entry
train_data.iloc[15] WORKS
#frequency table
train_data['Pclass'].value_counts(sort=False) WORKS
# bar plot of passenger classes (absolute)
train_data['Pclass'].value_counts(sort=False).plot('bar') DOES NOT WORK
plt.grid() DOES NOT WORK
plt.title('Absolute Häufigkeiten der Passagierklassen') WORKS
Does anyone have an idea, what I am doing wrong?