I have a DataFrame composed of a column of prices
df = pd.DataFrame({"Price": [0, 1, 0, 5, 0]})
I want to add a new column called "Type" which lists whether the price is Free (i.e. zero) or Paid (non-zero)
df["Type"] = ["Paid" for x in df["Price"]] # Make all of them read as "Paid"
df["Type"] = ["Free" for x in df["Price"] if x == "0"] # Convert the Free apps to read as "Free"
The second line here is spitting out an error message.
ValueError: Length of values (3) does not match length of index (5)
I presume this means it is spitting out a column of only 3 points, so the "Paid" points are not allowed for and thus erroring out. How can I fix this?