Update a DataFrame to Sum Elements Within

  dataframe, pandas, python

I have a data frame (df), consisting of float64, that I want to essentially "fold on itself." It is currently indexed at 0-30 and I need it at 0-9, combining elements that end in the same digit (0 with 10, 20, and 30; 1 with 11, 21; etc.) So something like:

for i in df:
    for x in df[i]:
        df[i][x] = df[i][x] + df[i][x + 10] + df[i][x + 20] + df[i][x + 30]

For some reason I get a KeyError outputting the first [i][x]

Source: Python Questions