I've run a string operation on the column of a dataframe to generate new column names in another array. So far so good.
columns = dfnum.columns.values
print(columns)
qcolumns = [x + 'q' for x in columns]
print(qcolumns)
When I try to run a for loop over these two arrays to generate the quantile cuts of the original values in the database I get this though:
for column in columns, qcolumn in qcolumns:
dfnumqcut = pd.qcut(dfnum[[column]],5)
dfnum[qcolumn] = dfnumqcut.codes
I get a bunch of errors per below. What I am trying to go is to get the qcuts and join them to the dataframe. I can do this column by column as per the below but there should be some way to do this using a for loop:
dfnumqcut = pd.qcut(dfnum[['Market Cap']],5)
dfnum['Market Capq'] = dfnumqcut.codes
1 for column in columns, qcolumn in qcolumns:
----> 2 dfnumqcut = pd.qcut(dfnum[[column]],5)
3 dfnum[qcolumn] = dfnumqcut.codesTypeError: unhashable type: 'numpy.ndarray'