Rearranging multiple stacked dataframes into 1 dataframe using panda in Python -


i'm new python , i'm not sure start this, although pandas seem option.

i use scientific instrument generates following excel data file.

https://docs.google.com/spreadsheets/d/1htramdpr_glrvdmykeamxwl01s57mmampwfae_q7yn8/edit?usp=sharing

here visual representation of data structure. https://drive.google.com/file/d/0b36iowuwp26jnhgttfnqv3vgzvu/view?usp=sharing

the structure of data represented in (from image link). import excel file python , re-order give structure depicted figure b.

i don't know how begin pointers appreciated.

ok, here's answer based on @edchum 's suggestions. imported data @ once , concatenated 2 dataframes example. next stage automatically recognise different dataframes within excel file instead of having manually define slices.

import pandas pd  df = pd.read_excel("test data.xlsx",header=none)  #import data  df1=df.ix[0:67,:] #slice first dataframe, give new headings , indices df1.columns=df1.ix[0,] df1=df1[1:] df1=df1.set_index(df1.ix[:,0])  df2=df.ix[69:136,:]  #slice second dataframe, give new headings , indices df2.columns=df2.ix[69,] df2=df2[1:] df2=df2.set_index(df2.ix[:,0])  frames=[df1,df2] #define frames combination of both databases  result=pd.concat(frames,axis=1) #concatenate    result=result.drop('wavelength', 1) #remove wavelength row  result.to_csv("result.csv") #export result 

Comments