I am currently working through the “Roller Coaster” project in the Data Visualization segment of the Data Science Course. I’m having trouble with task #8. I am attempting to create a function that takes a park name and creates a bar graph that displays all the rides in that park and the # of inversions. I initially ran my code without trying to format the axis object. Once I included those three lines, my code is producing the following error:
TypeError: bar() missing 2 required positional arguments: 'left' and 'height'
Here is my code:
def pltBarInversionByPark(parkName,csv): dataFrame = pd.read_csv(csv) selectParkDf = dataFrame[dataFrame.park == parkName] rideList =  numInversions =  for coaster in selectParkDf.name.values.tolist(): rideList.append(coaster) for num in selectParkDf.num_inversions.values.tolist(): numInversions.append(num) #print(rideList) #print(numInversions) plt.bar(range(len(rideList)), numInversions) ax = plt.bar() ax.set_xticks(range(len(rideList))) ax.set_xticklabels(rideList) plt.show() pltBarInversionByPark('Gardaland','roller_coasters.csv')
Thank you in advance!