Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas
- data = pandas.read_csv('crops_usa.csv')
- acres = list(data['Acres'])
- production = list(data['Production'])
- years = list(data['Year'])
- acres_usa = []
- production_usa = []
- for year in range(1980, 2020):
- acres_one_year = []
- production_one_year = []
- for index in range(len(data)):
- if years[index] == year:
- acres_one_year.append(acres[index])
- production_one_year.append(production[index])
- acres_usa.append(sum(acres_one_year))
- production_usa.append(sum(production_one_year))
- yield_usa = []
- for index in range(len(production_usa)):
- yield_usa.append(production_usa[index] / acres_usa[index])
- predict_acres=[] # создаем пустой список
- for index in range(1, len(acres_usa)): # цикл, перебирает все значения столбца, кроме первого, то есть 1980 года
- predict_acres.append(acres_one_year[index]*yield_usa[index-1]) #добавляем в пустой список результат умножения площади посевов за текущий год на урожайность за прошлый год
- print(predict_acres)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement