I have some data in a csv of the form:
L1 L2 X1 X2 Y1 Y2
'a' 'b' 1.1 1.6 3.0 3.2
I want to read it into a pandas DataFrame or numpy ndarray and transform it so:
L1 L2 X Y
'a' 'b' 1.1 3.0
1.6 3.2
The series X1...Y2 corresponds to measurements taken at regular time intervals of X,Y variables and my aim is to be able to feed them to a keras layer as input in that form along with the associated labels.
I've read in the csv using pandas.read_csv()
and extracted the columns I need into separate Series objects using pandas.DataFrame.filter
. Using stack()
on the series object seems to be relevant but I get errors on trying to concatenate the stacked series into a new dataframe with the label columns.
Responses using R or Python are welcome.