Python Forum
how to get the highest monthly average temperature?
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to get the highest monthly average temperature?
#3
You should use the module csv:
import csv


with open('world_temp_mean.csv') as fd:
    reader = csv.reader(fd)
    head = next(reader)
    data = list(reader)
Now you have data, which is a list. Each element in the list is one row of the data.
You can do an inline sort of the list. If you want to have different sorted new lists, you should use the built-in function sorted().

from operator import itemgetter


# avg highest tmp is in index 2
# sort by index 2
data.sort(key=itemgetter(2), reverse=True)
# or with lambda
data.sort(key=lambda x: x[2], reverse=True)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: how to get the highest monthly average temperature? - by DeaD_EyE - Jul-25-2017, 02:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My first temperature converter TheLowEndTheory 7 3,400 Oct-18-2020, 04:39 PM
Last Post: buran
  Monthly pollution rate RbaPhoenix 4 2,695 Mar-28-2020, 04:01 PM
Last Post: ibreeden
  Monthly report for pushed buttons chano 2 2,114 Oct-09-2019, 01:40 PM
Last Post: chano
  Methods that return the highest score from the list erfanakbari1 7 7,126 Mar-26-2019, 08:32 PM
Last Post: aankrose
  Temperature converter Help (ASAP) Edison_Weng 1 2,811 Apr-16-2018, 01:55 PM
Last Post: stranac
  Returning the highest value out of 3 values ComputerSkillet 2 3,842 Apr-28-2017, 03:16 AM
Last Post: volcano63
  Numerically determining the highest a ball travels when shot straight up JakeWitten 3 3,423 Apr-22-2017, 04:37 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020