How can I plot the monthly average temperature in Python?

Hello, I wrote this code in order to obtain a series of monthly weather observations at Helsinki for a period from 1960 to 2020 and then I saved the data to a local file using package pickle. I used the data available from the API provided by the Finnish Meteorological Institute.

import datetime
import requests
import lxml.etree as etree
from pprint import pprint
import pickle
import pandas as pd
import numpy as np

class FmiApi:
    """
    a minimalistic wrapper for the Finnish Meteorological Institute API    
    """
    def __init__(self):
        self.base_url = 'http://opendata.fmi.fi/wfs'
        self.fixed_params = {
                'service': 'WFS',
                'version':'2.0.0',
                }
        self.namespaces ={
                'wfs':'http://www.opengis.net/wfs/2.0',
                'gml':'http://www.opengis.net/gml/3.2',
                'BsWfs':'http://xml.fmi.fi/schema/wfs/2.0'
                }                   

    def get_monthly_obs(self, place, year, month, maxlocations=5):                
        """
        get monthly simple observation

        in:
            place [str]
            year [int]
            month [int]
            maxlocations [int] (optional)   

        out:
            dictionary with tuple of locations and times keys 
            and dictionary of parameter names and values as values
            tmon <=> temperature
            rrmon <=> rainfall
        """
        sdate = str(datetime.date(year,month,1))
        parms = {
            'request': 'getFeature',
            'storedquery_id': 'fmi::observations::weather::monthly::simple',
            'place':place.lower(),
            'maxlocations':'%d'%maxlocations,           
            'starttime': sdate + 'T00:00:00',
            'endtime': sdate + 'T00:00:00',
            }
        parms.update(self.fixed_params)                
        try:                                      
            resp = requests.get(self.base_url, params=parms, stream=True)
        except:
            raise Exception('request failed')
        if resp.status_code != 200: raise Exception('FMI returned status code %d'%resp.status_code)        
        resp.raw.decode_content=True 
        try:               
            root = etree.parse(resp.raw)
        except:
            raise Exception('parsing failed')          
        members = root.xpath('//wfs:member', namespaces=self.namespaces)                            
        weather = {}
        for member in members:                
            ppos = member.xpath('.//gml:pos', namespaces=self.namespaces)[0].text.strip()
            ppos = tuple([float(x) for x in ppos.split()])
            ptime = member.xpath('.//BsWfs:Time', namespaces=self.namespaces)[0].text.strip()
            if not ppos in weather:
                weather[ppos] = {}         
            pname = member.xpath('.//BsWfs:ParameterName', namespaces=self.namespaces)[0].text.strip()
            pvalue = member.xpath('.//BsWfs:ParameterValue', namespaces=self.namespaces)[0].text.strip()                                                      
            weather[ppos][pname] = (pvalue, ptime)       
        return weather

def test():
    api = FmiApi()
    weather = api.get_monthly_obs('kuusamo', 1985, 1)
    pprint(weather)

try:
    with open('wdata.pkl', 'rb') as f:
        data=pickle.load(f)

except:
    wheaters=[]
    for year in range(1960,2021):  
            for month in range(1,13):
                api = FmiApi()
                w = api.get_monthly_obs('oulu', year, month )

                wheaters.append(w)
                pprint(w)

    with open('wdata.pkl', 'wb') as f:
                pickle.dump(wheaters, f)

Now I want to use the local file to access the data in order to plot the monthly average temperature for the years 1960 to 2020. I wrote this code but it doesn't print the average temperature

def pest():



    df_weath = pd.read_csv('wdata.pkl', parse_dates=[0], infer_datetime_format=True)   
    df_weath.sort_values('Date', inplace=True, ignore_index=True)
    df_weath['Date'] = df_weath['Date'].dt.date   #convert to datetime objects


    #input()



    api = FmiApi()  #instantiate the api
    params = {            
                'place': u'helsinki',                       
                'maxlocations': '5',
                }
    d0 = df_weath['date'].values[0]
    d1 = df_weath['date'].values[-1]
    n_days = (d1 - d0).days + 1  #number of days between d0 and d1
    wdata = []
    for i_day in range(n_days):  
            date = d0 + datetime.timedelta(days=i_day)
            params['starttime'] = str(date) + 'T00:00:00'
            params['endtime'] = str(date) + 'T00:00:00'
            try:
                print('requesting weather data for %s'%str(date))
                weather = api.get_daily_obs(params)                                
            except:                
                print('getting weather failed, skipping')
                continue
            wdata.append(weather)


     #move weather data to a pandas dataframe (calculate avg over valid observations)
    date = []
    temps=[]
    variables = ['tday'] 

    for wobs in wdata:        
        avgs = {}
        for pos, obs in wobs.items():                   
            for var, xx in obs.items():                
                if not var in variables: continue

                date = datetime.date(1990,6,15)            
                if xx[0] != 'NaN':
                    val = float(xx[0])                    
                else:
                    val = None
                if not var in avgs: avgs[var] = []  
                if val != None: avgs[var].append(val)       
        vals = []
        for var in variables:  #calculate the average when available
            if len(avgs[var]) > 0:
                vals.append(sum(avgs[var])/len(avgs[var]))
            else:
                vals.append(None)
        wdata.append(temps)
        wdata.append(date)      

Can you help me to find what I am doing wrong? Or do you know any easier way to plot the monthly average temperature?
Thank you.

How to restrict input?

Hello, could anyone help me how can I make so the user could only enter numbers between 0...9 and letters a...f (A...F) on input? I have a code like this already

#MAKE_EXE#

DSEG SEGMENT 'DATA'

MSG DB 'Enter double digit hex number: $'

DSEG ENDS

SSEG SEGMENT STACK 'STACK'
DW 100h DUP(?)
SSEG ENDS

CSEG SEGMENT 'CODE'

;*******************************************

START PROC FAR

PUSH DS
MOV AX, 0
PUSH AX

; set segment registers:
MOV AX, DSEG
MOV DS, AX
MOV AH,09h
MOV DX, OFFSET MSG
INT 21h
XOR AX,AX
MOV AH,1H
INT 21H
MOV DL,AL
SUB DL,30H
CMP DL,9H
JLE M1
SUB DL,7H
M1:
MOV CL,4H
SHL DL,CL
INT 21H
SUB AL,30H
CMP AL,9H
JLE M2
SUB AL,7H
M2:
ADD DL,AL
RET
START ENDP

CSEG ENDS

END START

Hi everyone, I’m cesar.perezj989

Working part-time as a cashier at the Piggly Wiggly has given me a great opportunity to observe human behavior. Sometimes I think of the shoppers as white rats in a lab experiment, and the aisles as a maze designed by a psychologist. Most of the ratscustomers, I meanfollow a routine pattern, strolling up and down the aisles, checking through my chute, and then escaping through the exit hatch. But not everyone is so dependable. My research has revealed three distinct types of abnormal customer: the amnesiac, the super shopper, and the dawdler.

Key Press script?? just curious

Hey, so I'm still very new at programming/coding and for fun, I wanna make some sort of script.

For a offline fighting game. So let's say I press one key, it does one combo? does that make any sense?
I just wouldn't know how to go about that

is there any way I can impliment that in Javascript? or maybe even c++?? preferably javascript :)

Thank you!

Cloud Computing Security Parameters on Various Cloud Platforms

Abstract

Cloud Computing is currently a consistently emerging platform in the IT industry. As of now, big tech giants are providing cloud services to various industries as it is their essential policy to secure the architecture and enterprise data. 

With the increase in demand for cloud computing technologies, many tech giants are providing cloud automation services like Amazon Web Service (AWS), Microsoft Azure, Google Cloud Platform (GCP), IBM, SAP, Cloudera, and more.  

DolphinDB Partitioned Database Tutorial

DolphinDB is a super-fast distributed time-series database that offers powerful computing capabilities. DolphinDB has been widely used in quantitative finance, IoT, and various other fields that require high-performance data analysis with vast amounts of structured data.

1. Benefits of Partitioned Databases

Partitioned databases can significantly reduce latency and improve throughput.

How to Develop a Terraform Custom Provider

Terraform Introduction and Overview

Terraform is an infrastructure as code technology and it is used to create immutable infrastructure. It allows infrastructure to be expressed as code in a simple, human-readable language called HCL (HashiCorp configuration language). 

It supports managing resources across all the major cloud providers. Terraform is used to create, manage, and update infrastructure resources such as physical machines, VMs, network switches, containers, Kubernetes, and more. Almost any infrastructure type can be represented as a resource in Terraform. 

5 Reasons Why Your Software Value Stream Is Broken and How to Fix It

Teams are continuously discovering how every layer of the software production process affects the outcome, leading to software development model experimentation to achieve efficiency.

Subsequently, methodologies like DevOps have emerged, targeting greater speed of software product improvement by increasing the synergy between development and operations teams. As much as 70% of organizations are expected to be using value stream management by 2023.

Improving the Reader Experience With Adobe Embed API

The Adobe PDF Embed API provides a simple way for web developers to display PDFs on their web pages. While browsers provide good support for rendering PDFs, they do so in an "out of context" manner that takes over the entire screen. The PDF Embed API however lets you place a PDF within your site's layout, providing much better control over the position and size of the rendered document. This improved experience also provides deeper integration into the PDF viewer, letting developers listen for events and perform operations on the document. In this article, I'm going to demonstrate a simple, but hopefully really useful example of this.

Imagine a large document covering many pages, for example, a textbook. Your website users, potentially students, could work with the document over many weeks while school is in session. If the document is a few hundred pages long, it would be incredibly useful to remember where they were in the document when they start reading again. While a large PDF may have bookmarks, even then they could only be for chapters or other sections, not the exact page the user last read. Luckily, the Embed API provides a method to help with this. Let's take a look!

Making Accessibility More Accessible

Every person I’ve worked with has agreed that making the web more accessible is a good thing. We don’t want to disservice any of our users.

However, accessibility is nuanced, the work is not always straightforward, and responsibility can be unclear. After all, building websites requires many steps, and accessibility is impacted by the decisions at each stage; design, development, content creation.

Learn How to Use Vue and Spring Boot to Create a Single-Page App

In this tutorial, you'll create a single-page application (SPA) with a Spring Boot resource server and a Vue front-end client. You'll learn how to utilize JSON Web Tokens (JWTs) for authentication and authorization, using Spring Boot to configure the JWTs, with Okta as your OAuth 2.0 and OpenID Connect (OIDC) provider. You'll also learn how to use the Vue CLI to bootstrap a Vue client app and how to secure it using the Okta Sign-In Widget.

Okta is a computer security service provider with helpful information for safeguarding online applications. The Okta Sign-In Widget provides protection for front-end apps by letting you quickly add a secure login form that can be configured for single sign-on and social sign-on with external providers like Google, Facebook, and LinkedIn. It includes a PKCE implementation of the OAuth 2.0 authorization code flow (Proof Key for Code Exchange).

Getting Started With Pandas – Lesson 2

Introduction

We begin with the second post of our training saga with Pandas. In this article, we are going to make a summary of the different functions that are used in Pandas to perform Indexing, Selection, and Filtering.

Indexing, Selecting, and Filtering

Before we start, we are going to visualize ahead of our didactic dataset that we are going to follow to show the examples. It is a well-known dataset that contains wine information.

Comparison Between Site Reliability Engineering (SRE) and DevOps

Article Image

What is Site Reliability Engineering (SRE)?

Site Reliability Engineering happens when an organization looks at problems through the lens of a software problem. SRE is a software engineering approach where Site Reliability engineers use the software as a tool to manage systems, solve issues, and automate repetitive/mundane tasks. 

The primary aim of implementing this engineering practice is to develop a reliable and scalable software delivery system. The concept of this engineering practice was originally used by Google and creator Ben Treynor Sloss.

Getting Started With Pandas – Lesson 3

Introduction

We begin with the third post of our data science training saga with Pandas. In this article, we are going to make a summary of the different functions that are used in Pandas to perform Iteration, Maps, Grouping, and Sorting. These functions allow us to make transformations of the data giving us useful information and insights.

Iteration, Maps, Grouping, and Sorting

The 2009 data set  ‘Wine Quality Dataset’ elaborated by Cortez et al. available at UCI Machine Learning, is a well-known dataset that contains wine quality information. It includes data about red and white wine physicochemical properties and a quality score.