Issue
I have the following file:
"j"; "x"; y
"0"; "1"; 5
"1"; "2"; 6
"2"; "3"; 7
"3"; "4"; 8
"4"; "5"; 3
"5"; "5"; 4
Which I read by:
df = pd.read_csv('test.csv', delimiter='; ', engine='python')
Then I print print df
and see:
"j" "x" y
0 "0" "1" 5
1 "1" "2" 6
2 "2" "3" 7
3 "3" "4" 8
4 "4" "5" 3
5 "5" "5" 4
Instead, I would like to see:
j x y
0 0 1 5
1 1 2 6
2 2 3 7
3 3 4 8
4 4 5 3
5 5 5 4
How to remove the double quotes?
Solution
I did it with:
rm_quote = lambda x: x.replace('"', '')
df = pd.read_csv('test.csv', delimiter='; ', engine='python',
converters={'\"j\"': rm_quote,
'\"x\"': rm_quote})
df = df.rename(columns=rm_quote)
Answered By - KcFnMi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.