I am using pandas which very efficiently sorts/filters the data they way I need.
This code worked fine, until I changed the last column to a complex number; now I get an error.
return self._cython_agg_general('mean') raise DataError('No numeric types to aggregate') pandas.core.groupby.DataError: No numeric types to aggregate
The error refers to my eighth column (with the complex numbers) since I want the mean value I cannot find a way to convert the object to a complex number (from what I understand pandas now support complex numbers).
This is the code I use.
import numpy as np
import pandas as pd
df = pd.read_csv('final.dat', sep=",", header=None)
df.columns=['X.1', 'X.2', 'X.3', 'X.4','X.5', 'X.6', 'X.7', 'X.8']
df1 = df.groupby(["X.1","X.2","X.5"])["X.8"].mean().reset_index()
After that I get the error described above.
When I read my file, this is the df output.
<class 'pandas.core.frame.DataFrame'>
Int64Index: 21266 entries, 0 to 21265
Data columns (total 8 columns):
X.1 21266 non-null values
X.2 21266 non-null values
X.3 21266 non-null values
X.4 21266 non-null values
X.5 21266 non-null values
X.6 21266 non-null values
X.7 21266 non-null values
X.8 21266 non-null values
dtypes: float64(4), int64(3), object(1)
This is a small sample of the input file.