I am starting with a Pandas data frame that looks like this:
Type Date Number
1 A x y
2 B x y
3 A x y
4 B x y
5 A x y
I want to create separate time series for Type A data and Type B data separately. What is the most efficient way of doing this?
I am considering creating two different data frames from this where each data from only has data from one type and then converting each of the separate data frames to a series. However I don't know how to do this either.
Extended question: Is there a way to do this if you don't even know how many different types there are?
So far I tried checking to see if the type is of the type I want by using df["type"] == A, and this doesn't give me a full data frame back just a data frame saying if the type was true or false.
Additional information:
My goal is to create separate pandas time series using the date and number data for type A and type B separately.
I tried the following:
df.groupBy("Type").apply(lambda x: x.Date)
The above function works but only returns one column.
df.groupBy("Type").apply(lambda x: (x.Date, x.Number))
The above function doesn't work and returns something that is not what I want at all.
Expected Output:
Type Date Number
A 1 x y
3 x y
5 x y
B 2 x y
4 x y