Search code examples
pythonpandasdataframesyntax-errornaming

Dataframe in pandas synthax error about the :


I do have a problem in the start if my code:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


V1 = pd.read_excel('S1V1.xlsx', skiprows=9, parse_dates=[['Date','Time']])
V2 = pd.read_excel('S1V2.xlsx', skiprows=9, parse_dates=[['Date','Time']])

V1V2=pd.DataFrame({V1['Date_Time'],'S1V1':V1['TEMPERATURE'],'S1V2':V2['TEMPERATURE']})

When I'm running it, it says that I have a SynthaxError: invalid syntax over the 'S1V2':V2['TEMPERATURE'] especially pointing the :.

I'm really don't see my mistake. Is there anyone who sees it ?

Thanks a lot!


Solution

  • You are missing the column name of for the first column (V1['Date_Time']):

    Try:

    V1V2=pd.DataFrame({'Date_Time':V1['Date_Time'],'S1V1':V1['TEMPERATURE'],'S1V2':V2['TEMPERATURE']})