I am working with the scikit learn Wisconsin breast cancer dataset.
I've created a DataFrame with last columns like so:
worst concave points worst symmetry worst fractal dimension target
0 0.26540 0.4601 0.11890 0.0
1 0.18600 0.2750 0.08902 0.0
2 0.24300 0.3613 0.08758 0.0
I'm trying to create a pd.Series based on target where it can be 0 or 1 and assign that to an index of 'malignant', 'benign'
I've tried the following:
output = df.Series([0,1], index= ['Malginant', 'Benign'])
with output being:
Enter code here...no 0
yes 1
dtype: int64
and also tried a mapping:
status = {0:'Malignant', 1:'Benign'}
cancerdf['target'] = pd.to_numeric(cancerdf['target'], errors='coerce').fillna(2).astype(int).map(status)
where cancerdf is my whole dataframe with the target column
however, this throws a type error:
TypeError: tuple indices must be integers or slices, not str
I'm trying to understand how to get this kind of mapping from the column, in order to move to further processing.
thanks very much.