0

I have in my Dataframe Float type columns with few '\t' while all other values are float type.

I cannot remove them without making them the float values 'NaN'. I used following command, then all the float values become NaN.

df["col"] = df["col"].str.replace("\t","")

[1]: https://i.stack.imgur.com/Btx9k.png

I tried few other things as well (like astype(float), isnumeric() etc.) but nothing seem to work. I know it seems like a simple thing, but I am unable to solve.

SJa
  • 487
  • 4
  • 14

1 Answers1

1

I have found the solution which is as follows

for r in range(0,len(df)):
    if type(df['col_name'][r]) == str:
        df['col_name'][r] = df['PCC PHY Throughput DL_All Logs'][r].replace("\t", "") 
        # If want to convert to NaN so that later drop it, uncomment the following and comment the above line          
        #df['PCC PHY Throughput DL_All Logs'][r] = np.nan
SJa
  • 487
  • 4
  • 14