import dascore as dc
import pandas as pd
# get example patch and create example dataframe
pa = dc.get_example_patch()
distance = pa.coords.get_array("distance")[::10]
df = pd.DataFrame(distance, columns=['distance'])
df['x'] = df['distance'] * 3 + 10
df['y'] = df['distance'] * 2.5 - 10
# attach dataframe to patch, interpolating when needed. This
# adds coordinates x and y which are associated with dimension distance.
patch_with_coords = pa.coords_from_df(df)coords_from_df
coords_from_df(
     self: Patch ,
     dataframe: DataFrame ,
     units: dict[dict[str, str], None] = None,
     extrapolate: bool = False,
 )-> ‘PatchType’
Update non-dimensional coordinate of a patch using a dataframe.
Parameters
| Parameter | Description | 
|---|---|
| dataframe | Table with a column matching in title to one of patch.dims along with other coordinates to associate with dimension. Example one column matching distance axis and then latitude and longitude attached to the distances. | 
| units | Dictionary mapping column name in dataframe to its units. | 
| extrapolate | If True, extrapolate outside provided range in dataframe. | 
Examples
Note
- Exactly one of the column names in the dataframe must map to one of the patch.dims. This will either add new coordinates, or update existing ones if they already exist. 
- This function uess linear extrapolation between the nearest two points to get values in patch coords that aren’t in the dataframe. 
