Advertisement
Vitaliy_Novichikhin

7.9.1 ЯП ошибка нет значения года 1981 в списке

Feb 5th, 2022
1,361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. #7.9.1 ошибка нет значения года 1981 в списке
  2. import pandas, seaborn
  3. data = pandas.read_csv('crops_usa.csv')
  4.  
  5. acres = list(data['Acres'])
  6. production = list(data['Production'])
  7. years = list(data['Year'])
  8.  
  9. acres_usa = []
  10. production_usa = []
  11.  
  12. for year in range(1980, 2020):
  13.     acres_one_year = []
  14.     production_one_year = []
  15.     for index in range(len(data)):
  16.         if years[index] == year:
  17.             acres_one_year.append(acres[index])
  18.             production_one_year.append(production[index])
  19.     acres_usa.append(sum(acres_one_year))
  20.     production_usa.append(sum(production_one_year))
  21.  
  22. yield_usa = []
  23.  
  24. for index in range(len(production_usa)):
  25.     yield_usa.append(production_usa[index] / acres_usa[index])
  26. years_numbers = list(range(1980, 2020))
  27.  
  28. error_acres = []
  29.  
  30. for index in range(len(production_usa)):
  31.     error_acres.append(production_usa[index]-yield_usa[index-1]*acres_usa[index])
  32.  
  33. seaborn.barplot(x=years_numbers[1:], y=error_acres)
  34.     # ваш код здесь
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement