Data_ing
Data_ing

Reputation: 107

Pandas - AttributeError: 'Series' object has no attribute 'upper'

I have this error and I don't know how to solve it.

Here is my code :

time_start = data_h_df['hour']
frequency = data_h_df['FREQUENCY']
timezone = data_h_df['TIMEZONE']
outputMode = OutputMode('EEA',time_start, frequency, pytz.timezone(timezone),CONST_MODE_CONT,IDCase1())

When I don't use variables but I put the values directly in parameters like this, I don't have an error :

outputMode = OutputMode('EEA','06:00:00','08:00:00',pytz.timezone('Europe/Paris'),CONST_MODE_CONT,IDCase1())

I don't know if it can help, these columns have this form in the dataframe :

hour         FREQUENCY      TIMEZONE
06:00:00     08:00:00       Europe/Paris

Upvotes: 1

Views: 5861

Answers (2)

Chris
Chris

Reputation: 608

Try

time_start = data_h_df['hour'][0]
frequency = data_h_df['FREQUENCY'][0]
timezone = data_h_df['TIMEZONE'][0]

It's a type error from the Data frame: you're accessing the column, which is returned as a Pandas Series. With the [0] you get the actual element within the Series.

Upvotes: 1

Simon Hawe
Simon Hawe

Reputation: 4539

Your are extracting columns from your dataframe here. These columns are of type Series and your are passing those Series objects to OutputMode. Probably, you just want to get the first entry of each column/series, which you get by

time_start = data_h_df['hour'][0]
frequency = data_h_df['FREQUENCY'][0]
timezone = data_h_df['TIMEZONE'][0]

Upvotes: 1

Related Questions