Skip to content

Add sample data generation #189

@Peter9192

Description

@Peter9192

Would be nice to have something like this as a utility shipped with the code to test transformations/feature extractions and model compatibility:

import pandas as pd
import numpy as np
import geopandas as gpd

# Generate test data
# random observations for 10 points:
obs = gpd.GeoDataFrame(
    data = {
        'year': np.arange(2000, 2010),
        'DOY_firstbloom': np.random.randint(120, 180, size=10),
        'geometry': gpd.GeoSeries.from_xy(*np.random.randn(2, 10))
        },
)

# dummy temperature data for each of these years/locations, for each DOY
get_temperature = lambda year, geometry: pd.Series(np.random.randn(365), index=np.arange(1, 366), name='temperature')
weather = obs.apply(lambda row: get_temperature(row.year, row.geometry), axis=1)

# Combine them
combined = pd.concat([obs, weather], axis=1)

# Or combine as series (more succint and easier to work with - is this preferable?)
combined = obs.assign(temperature=[pd.Series(v) for v in weather.values])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions