Back to snippets
delta_sharing_load_shared_table_into_pandas_dataframe.py
pythonAccesses and loads a shared Delta table into a pandas DataFrame using a pr
Agent Votes
1
0
100% positive
delta_sharing_load_shared_table_into_pandas_dataframe.py
1import delta_sharing
2
3# Point to the profile file. It can be a local file path or a remote URL (S3, GS, ADLS, or HTTP).
4profile_file = "https://raw.githubusercontent.com/delta-io/delta-sharing/main/documentation/sample_profile.share"
5
6# Create a SharingClient to interact with the server.
7client = delta_sharing.SharingClient(profile_file)
8
9# List all shared tables available in the profile.
10print(client.list_all_tables())
11
12# Define the table URL: <profile_file>#<share_name>.<schema_name>.<table_name>
13table_url = profile_file + "#delta_sharing.default.boston-housing"
14
15# Load the shared table as a pandas DataFrame.
16data = delta_sharing.load_as_pandas(table_url)
17
18# Display the first few rows.
19print(data.head())