Below is my code, which simply groups together and averages sets of rows. For the life of me, I can't understand why a column is dropped in the final result.
import pandas as pd
def group_rows(dataframe1):
incr = 10
dataframe3 = pd.DataFrame()
for i in range(0,len(dataframe1.index),incr):
tmp = dataframe1[i:i+incr].mean()
dataframe3 = dataframe3.append(tmp, ignore_index=True)
print dataframe3.to_string()
group_rows(pd.read_csv('sample.csv')) # Inputs the CSV file whose snapshot is shown below
The CSV file sample.csv
is the input for the group_rows()
function above, and consists of 12 columns, and many rows. The returned result from this function has 11 columns instead of 12.
A snapshot of the output is given below.