'how to replace double quotes and nan with null in pandas?

I am reading a txt file via pandas. Trying to replace quotes (") with (null), but no luck. Also getting nan values, which is not needed. How to resolve this ?

code:

import pandas as pd 
df1 = pd.read_csv("file.txt", sep = '\t')
df1['location'] = df1['location'].astype(str)   
df1['location'] = df1['location'].replace('"', '')

input: input

output of code: current output

expected output: expected output



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source