Skip to content

Instantly share code, notes, and snippets.

View alexsalr's full-sized avatar

Alejandro Salazar-Romero alexsalr

  • Mexico
View GitHub Profile
@jlln
jlln / separator.py
Last active November 9, 2023 19:59
Efficiently split Pandas Dataframe cells containing lists into multiple rows, duplicating the other column's values.
def splitDataFrameList(df,target_column,separator):
''' df = dataframe to split,
target_column = the column containing the values to split
separator = the symbol used to perform the split
returns: a dataframe with each entry for the target column separated, with each element moved into a new row.
The values in the other columns are duplicated across the newly divided rows.
'''
def splitListToRows(row,row_accumulator,target_column,separator):
split_row = row[target_column].split(separator)
@teoliphant
teoliphant / simple_interpolation.py
Last active April 16, 2023 09:30
Vectorized linear interpolation
# The kernel function is
# roughtly equivalent to new[:] = np.interp(xnew, xvals, yvals)
# But this is broadcast so that it can be run many, many times
# quickly.
# Call using ynew = interp1d(xnew, xdata, ydata)
# ynew.shape will be xnew.shape
# Also, ydata.shape[-1] must be xdata.shape[-1]
# and if ydata or xdata have ndim greater than 1, the initial dimensions
# must be xnew.shape:
@devisperessutti
devisperessutti / eoworkflow_timelapse.py
Last active July 5, 2024 05:32
Timelapse EOWorkflow
# generic imports
import os
import imageio
import datetime
import numpy as np
# sentinelhub-py and eo-learn imports
from sentinelhub.geometry import BBox
from sentinelhub.constants import CRS, DataSource
from eolearn.core import EOTask, FeatureType, LinearWorkflow