Advertisement
Vitaliy_Novichikhin

7.9.2 ЯП ошбика, но график строится

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