I have a dataset with very big numbers. I would like to facilitate reading by using the humanize.intword
function in all columns except the date.
When I select only one column, it works:
pred_df["Predictions"].apply(lambda x: humanize.intword(x))
When I try to select other numeric columns, I get an error:
pred_df.apply(lambda row : humanize.intword(row['Predictions'],row['Lower'], row['Upper']), axis = 1)
TypeError: sequence item 0: expected str instance, float found
I also tried list comprehensions as suggested in this post https://stackoverflow.com/questions/16476924/how-to-iterate-over-rows-in-a-dataframe-in-pandas
but I am probably doing something wrong. It works for one single column:
[humanize.intword(x) for x in pred_df["Predictions"]]
When I try over different columns I get an error:
[humanize.intword(row1, row[11]) for row in zip(pred_df["Predictions"],pred_df["Lower"])]
IndexError: tuple index out of range
My dataframe contains 12 rows and 4 columns. Can you help me to understand what is the problem?