ZazoTazo

Dataset1

Mar 3rd, 2021
607
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2.  
  3. def calculateTemperature(data, temperature):
  4.     new_temp = []
  5.     for index, item in dataset.iterrows():
  6.         result = item['Air Temperature (C°)'] - float(input)
  7.         if result >= 0:
  8.             new_temp.append(result)
  9.         else:
  10.             new_temp.append(0)
  11.     dataset['CDD'] = new_temp
  12.     dataset.to_excel('output.xlsx')
  13.  
  14. def printDate(data):
  15.     for row in data.head().iterrows():
  16.         print(row[0].day_name(), row[0].day, row[0].month_name(), row[0].year)
  17.  
  18. def dates(data):
  19.     months = []
  20.     years = []
  21.     for row in data.iterrows():
  22.         if row[0].month_name() not in months:
  23.             months.append(row[0].month_name())
  24.     for row in data.iterrows():
  25.         if row[0].year not in years:
  26.             years.append(row[0].year)
  27.     months.append(months.pop(months.index('December')))
  28.    
  29.     print(months)
  30.     print(years)
  31.  
  32. if __name__ == "__main__":
  33.     dataset = pd.read_excel('test.xlsx', index_col=0, engine='openpyxl')
  34.     # temperatureInput = eval(input("Enter a temperature value (0-100): "))
  35.     # calculateTemperature(dataset, temperatureInput)
  36.     # printDate(dataset)
  37.     dates(dataset)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×