I tried to change the values in those columns which dtypes are numeric values. But my code doesn't work.
dataframe name: mergedDF
for c, dtype in zip(mergedDF.columns,mergedDF.dtypes):
if dtype == np.int64:
mergedDF[c].where(mergedDF[c]> 0,1)
It basically changed nothing. When I tried to assign variable names it changed everything to 1
if dtype == np.int64:
mergedDF[c] = mergedDF[c].where(mergedDF[c]> 0,1)
input:
col1 col2 col3
1 2 0
4 0 1
2 2 0
expected output:
col1 col2 col3
1 1 0
1 0 1
1 1 0
Only 2 dtypes in my original table.
case_history object # text column
cleaned_text object # text column
401k deduction int64 # 0-10
assistance manual int64 # 0-10
assistance quick int64 # 0-10