Semantic link functions for meteostat package

0.14.0 · active · verified Wed Apr 15

This library provides semantic link functions specifically designed for integrating Meteostat historical weather data with FabricDataFrames within Microsoft Fabric. It enables the enrichment of tabular data with weather-related insights, exposing these functions dynamically on FabricDataFrames. The library is currently at version 0.14.0 and is part of the broader Semantic Link ecosystem, which typically sees frequent updates aligning with Microsoft Fabric's release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the general pattern of using semantic link functions. It involves creating a FabricDataFrame (or reading one from a semantic model in a Microsoft Fabric notebook) and then applying a semantic function to enrich it. While the exact function names for Meteostat are dynamically discovered in Fabric, this example illustrates the conceptual flow. The library integrates with the `sempy.fabric.FabricDataFrame` to provide weather data enrichment capabilities.

import pandas as pd
from sempy.fabric import FabricDataFrame
import datetime

# Assume 'fabric' is available in the Microsoft Fabric environment
# and can read from a semantic model or lakehouse.
# For a runnable example outside Fabric, we'll create a dummy FabricDataFrame.

# Create a sample FabricDataFrame with relevant columns
df = FabricDataFrame({
    'city': ['London', 'Paris', 'Berlin'],
    'latitude': [51.5074, 48.8566, 52.5200],
    'longitude': [-0.1278, 2.3522, 13.4050],
    'date': [datetime.date(2023, 1, 1), datetime.date(2023, 1, 1), datetime.date(2023, 1, 1)]
})

print("Original FabricDataFrame:")
print(df)

# In a Fabric notebook, a semantic function (e.g., 'add_weather_data')
# would be dynamically discoverable via autocomplete on the FabricDataFrame.
# The exact function name depends on the implementation within semantic-link-functions-meteostat.
# This is a conceptual example of how such a function would be called.
# For demonstration, we'll simulate an enrichment.

# Example of conceptually calling a semantic function to enrich with weather data
# (Actual function name and parameters would be discovered in Fabric Notebooks)
# try:
#     enriched_df = df.add_meteostat_weather_data(date_column='date', lat_column='latitude', lon_column='longitude')
#     print("\nFabricDataFrame enriched with weather data:")
#     print(enriched_df)
# except AttributeError:
#     print("\nNote: The exact semantic function like 'add_meteostat_weather_data' ")
#     print("      is dynamically exposed in Microsoft Fabric notebooks. \n      This local example demonstrates the intended usage pattern.")

# A more concrete placeholder showing expected interaction in Fabric
# In a Fabric notebook, you would typically read a table first:
# df_from_fabric = fabric.read_table('MyDataset', 'SalesData')
# Then apply a semantic function:
# enriched_df = df_from_fabric.add_meteostat_weather_data()

print("\nFurther processing would involve calling specific semantic functions exposed on the FabricDataFrame.")
print("These functions would dynamically appear in autocomplete within Microsoft Fabric notebooks.")

view raw JSON →