I'm trying to use iterrows() for a DataFrame... The Column could have a value such as Fred,William,John and I want to count how many names are listed. The following code works great...
for index, row in search_df:
print(len(row["Name"].split(",")))
However, when I try to actually use the value from len(), it will give me errors... Such as:
for index, row in search_df:
row["Number of Names"] = len(row["Name"].split(","))
That will give me an error.. 'float' object has no attribute 'split' or something..
And when I do:
row["Number of Names"] = len(row["Name"].str.split(","))
It will give the error: 'str' object has no attribute 'str'
Looks like a string, but it's a float... Try to treat it as a string, it's already a string... Frustration...