I have a pandas dataframe of 45 variables of varying data types and I am using 'dython.nominal' package to create a matrix of associations between each of those variables.
I then want to:
A: subset my dataframe (filter by geographical location) and compute an association matrix on that subset, then
B: create and add to second pandas dataframe with the columns of a target variable from the dataframe created in step A.
The resulting dataframe will then be a matrix of correlations with column indices being georgraphical location and row indices being the other 44 variables.
The code I have so far is:
import pandas as pd
from dython.nominal import compute_associations
temp_df = pd.DataFrame
for item in postcode_partials:
temp_data = all_data[all_data['Post Code'].str.contains(item)]
temp_matrix = compute_associations(temp_data, nominal_columns='auto', mark_columns=True, theil_u=True)
temp_df[item] = temp_matrix['Last Balance (con)'].values
I keep getting the following error:
'type' object does not support item assignment
I'm quite new to pandas as I haven't had much experience of using them in practice. Any help would be gratefully received.
Thanks Andy