Zip them into a folder structure: python/lib/python3.x/site-packages/ . Upload this zip as a new Layer in the AWS Lambda Console .
This script fetches real-time data for earthquakes with a magnitude of 1.0 or higher from the last 24 hours: Download EARTHQUAKE MAGNIDUTE DATA with lambda (1) xlsx
import json import pandas as pd import requests import boto3 from io import BytesIO def lambda_handler(event, context): # 1. Fetch data from USGS API (GeoJSON format) url = "https://usgs.gov" response = requests.get(url) data = response.json() # 2. Extract relevant magnitude and location details features = data['features'] quakes = [] for f in features: prop = f['properties'] quakes.append({ 'Magnitude': prop['mag'], 'Place': prop['place'], 'Time': pd.to_datetime(prop['time'], unit='ms'), 'Type': prop['type'] }) # 3. Convert to Excel using Pandas df = pd.DataFrame(quakes) excel_buffer = BytesIO() with pd.ExcelWriter(excel_buffer, engine='openpyxl') as writer: df.to_excel(writer, index=False, sheet_name='Earthquakes') # 4. Upload to S3 (optional, for storage) s3 = boto3.client('s3') bucket_name = "your-bucket-name" s3.put_object(Bucket=bucket_name, Key="earthquakes.xlsx", Body=excel_buffer.getvalue()) return { 'statusCode': 200, 'body': "XLSX file successfully generated and stored." } Use code with caution. Zip them into a folder structure: python/lib/python3
Set the timeout to at least 1 minute , as fetching and processing data can take time. Fetch data from USGS API (GeoJSON format) url
Imaginar es un poder: idear, concebir y crear algo nunca visto. Es construir un mundo mejor para que sea hogar del otro. Es hacer conexiones deslumbrantes con lo que sabemos. Imaginar hace grande el conocimiento. Es el camino para ir a todas partes y llenarse del mundo con libertad, para innovar en él y tomar riesgos. Imaginar es educar y maravillarse. Es la llave del aprendizaje que desarrolla el pensamiento abstracto y el pensamiento crítico. Es encontrar soluciones a los problemas. Imaginar es la emoción de saber cómo relacionarse con los demás y con el entorno. Es avanzar: ir de la percepción al aprendizaje significativo para realizar creaciones artísticas, científicas y técnicas. Imaginar es un poder para mejorar nuestra comunidad y contribuir al cuidado del planeta.
