Issue
I am use a vectorize code to create a list of pandas.Intervals.
Example:
a = np.array([1, 5, 10])
b = np.array([3, 8, 12])
Desired output:
What I have tried:
A:
pd.Intervals(a,b)
B:
df['c'] = tuple(np.array([a, b]).T)
df['c'] = df['c'].astype(pd.Intervals)
Solution
I used Riley reference to find the solution: using pandas.arrays.IntervalArray.from_arrays
The solution:
a = np.array([1, 5, 10])
b = np.array([3, 8, 12])
c = pd.arrays.IntervalArray.from_arrays(a, b)
Answered By - Ilan12
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.