Struggling to convert a float 12345678.0 to a string 12345678 Gone through a few different solutions I've found in SO, but can't seem to get to the finish line, the decimal point will not drop.
Here is what I've tried
df["variable"]= df["variable"].astype(str)
df["variable"]= df["variable"].astype(int).astype(str)
# old lambda solution
cols = ['variable']
for col in cols:
df[col] = df[col].apply(lambda x: int(x) if x == x else "")
# convert int to string
df["variable"] = df["variable"].astype(str)
You can do it simply like this:
df['variable'] = df['variable'].astype(int, errors = 'ignore').astype(str)