I am working with a dataframe having datetime as index in the form DD/MM/YYYY HH:mm:ss, followed by a series of columns named as Sitename_Parameter. For the same Sitename I have different parameters.
I'd like to convert it into a long format with the datetime and the name of the sites as indices and the Parameters as columns.
I am using this code:
df=pd.wide_to_long(df, stubnames=['Sitename1','Sitename2',...,'Sitenamen'], i=["Timestamp"], j="Parameter",sep='_', suffix=r'\w+')
but I am encountering two issues:
- Data must be 1-dimensional, when I use Timestamp as index. I don't get this error when I use a standard index.
- This code places the Sitenames as columns and the Parameters as rows, which is the opposite of what I want. But if I replace the sitenames with the parameters into stubnames I get an error.