0

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.

irfus
  • 1
  • 3
  • Thanks for the heads up! I'm going through the answers there now. I'll leave the question open here for a python specific solution, for now. – irfus Sep 01 '16 at 09:19
  • Found python/pandas based answers at [link](http://stackoverflow.com/questions/36451918/pandas-reshape-wide-dataframe-to-multi-indexed-long) I needed to search for "wide to long", I guess, before posting this Q. – irfus Sep 01 '16 at 09:37

0 Answers0