Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- def calculateTemperature(data, temperature):
- new_temp = []
- for index, item in dataset.iterrows():
- result = item['Air Temperature (C°)'] - float(input)
- if result >= 0:
- new_temp.append(result)
- else:
- new_temp.append(0)
- dataset['CDD'] = new_temp
- dataset.to_excel('output.xlsx')
- def printDate(data):
- for row in data.head().iterrows():
- print(row[0].day_name(), row[0].day, row[0].month_name(), row[0].year)
- def dates(data):
- months = []
- years = []
- for row in data.iterrows():
- if row[0].month_name() not in months:
- months.append(row[0].month_name())
- for row in data.iterrows():
- if row[0].year not in years:
- years.append(row[0].year)
- months.append(months.pop(months.index('December')))
- print(months)
- print(years)
- if __name__ == "__main__":
- dataset = pd.read_excel('test.xlsx', index_col=0, engine='openpyxl')
- # temperatureInput = eval(input("Enter a temperature value (0-100): "))
- # calculateTemperature(dataset, temperatureInput)
- # printDate(dataset)
- dates(dataset)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement