piso icon indicating copy to clipboard operation
piso copied to clipboard

ENH: from_frame

Open venaturum opened this issue 4 years ago • 0 comments

Describe the solution you'd like

Add new top-level function into ndframe.py - piso.from_frame

It allows fast creation of interval arrays from vector data in dataframes

Additional context

sig:

def from_frame(frame, start, end, group=None, index=False)

  • frame is pandas.DataFrame
  • start, end, group all strings
  • index is boolean and indicate is IntervalIndex, or IntervalArray should be produced.
import piso

df = pd.DataFrame(
    {
        "group";["A", "B", "A", "B"],
        "start":[1,3,5,7],
        "end":[2,4,6,8],
    }
)

piso.from_frame(df, "start", "end", "group")

# produces Series, indexed by "group", where values are interval arrays of type indicated by "index" param

venaturum avatar Nov 02 '21 09:11 venaturum