0

I have data on energy generation for every quarter hour by utility. However, I need the generation by day, which is why I deleted the H-column displaying the time in hours and tried summing it up for every day for every utility. It does not appear to be working and I always get the error: TypeError: only integer scalar arrays can be converted to a scalar index. I am new to Python and could not quite place it since all data in my DataFrame have the type int65 except for the Date. So how would I sum it up over all columns based on days? Here is what I tried so far:

EE = pd.DataFrame(data = RE)
EE['Datum'] = pd.to_datetime(EE['Datum'])
EE['Datum'] = pd.DatetimeIndex(EE['Datum'])

EE.columns = [["Datum", "H", "BM", "WK", "WOff", "WOn", "PV", "SE", "KE", "BK", "SK", "EG", "PS", "SK"]]

del EE["H"]
EBM = EE[["Datum", "BM"]]
EBM.groupby("Datum").sum()

I did create another Dataframe EBM since the error for EE.groupby("Datum").sum() was Grouper for 'Datum' not 1-dimensional but a smaller data frame does not solve this.

This is what my dataframe looks like:

Date    BM  WK  WOff    WOn PV  SE  KE  BK  SK  EG  PS  SK
0   12/1/2018   1   0   0   0   0   0   0   0   0   0   0   0
1   12/1/2018   1   0   0   0   0   0   0   0   0   0   0   0
2   12/1/2018   1   266 0   0   0   0   0   0   0   0   0   0
3   12/1/2018   1   0   0   0   0   0   0   0   0   0   0   0
4   12/1/2018   1   0   0   0   0   0   0   0   0   0   0   0

These are the datatypes:

Date    object
BM       int64
WK       int64
WOff     int64
WOn      int64
PV       int64
SE       int64
KE       int64
BK       int64
SK       int64
EG       int64
PS       int64
SK       int64
dtype: object

But changing to float didnt solve my problem either. And this is what it should look like.

    SPC
Year    
1927-12-30  17.660000
1928-01-03  17.760000
1928-01-04  17.719999
1928-01-05  17.549999
1928-01-06  17.660000

I do want to sum up the data in each column so that I have only daily data. Hope this helps.

Okay, I am really confused at this point. I did perform the exact same operations on a different dataset that was stored in a regular csv file providing similir data, though in American Date format which correspends to my locale. It worked out perfectly fine but the datatype was float64 instead of integer. If I perform the same operations on the dataset above which is a csv-utf-8-file in German Date format, it will not work. I did change the date in Excel manually to American Date format via concate but it did not change anything.

Jan
  • 1
  • 1

0 Answers0