I have a couple of function which filter a dataframe of different customers' features and return the filtered dataframe as below:
stg_1 = strategy_1_filtering(df_1)
stg_2 = strategy_2_filtering(df_2)
Now, I make an adjacency matrix to based on Customer IDs and strategies:
d = {'stg_1':stg_1['Customer_ID'],'stg_2':stg_2['Customer_ID']}
df = pd.DataFrame({k: dict.fromkeys(v, True) for k, v in d.items()}).fillna(False)
And the result is something like this:
stg_1 | stg_2 | |
---|---|---|
385986.0 | True | True |
363015.0 | True | False |
411847.0 | True | True |
413369.0 | True | True |
401081.0 | True | False |
I have tried to change the name of first column using this code:
df.columns.values[0] = "Customer_ID"
But it did not work. To understand the problem I printed shape and column names of the dataframe:
print(df.shape)
print(df.columns)
The results:
(1155, 2)
Index(['stg_1', 'stg_2'], dtype='object')
In this case, when the dataframe cannot detect even the first column, what should I do?