Semantic link functions for meteostat package
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
- gotcha This library, as part of the Semantic Link ecosystem, is primarily designed and supported for use within Microsoft Fabric notebooks. Its functionality relies on the Fabric runtime and its specific environment.
- breaking The `pandas_convert_dtypes` parameter in `fabric.evaluate_measure` (from the core `semantic-link-sempy` package, which this library depends on) was removed in version 0.3.6. Using it in newer versions will result in a `TypeError`.
- gotcha While the core `semantic-link` (SemPy) package might be preinstalled in Fabric Spark 3.4 and above, the `semantic-link-functions` package (which includes this Meteostat-specific library) may still need manual installation or an update to access the latest features and functions.
- gotcha Semantic Link functions are dynamically discovered and exposed as methods on a `FabricDataFrame` or `FabricSeries`. This means there isn't a direct `import` statement for specific functions from this library; rather, they appear via autocomplete on your DataFrame object.
Install
-
%pip install semantic-link-functions-meteostat -
%pip install semantic-link
Imports
- FabricDataFrame
from sempy.fabric import FabricDataFrame
Quickstart
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.")