Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

first column name is circled by double quote after reading from csv

i use the following codes to read data from csv using read_csv, but after i print the result and found the first column name is circled by double quote, but other column names are normal,

import pandas as pd
import numpy as np
import csv

path1 = "C:\\Users\\IBM_ADMIN\\Desktop\\ml-    1m\\SELECT_FROM_HRAP2P3_SAAS_ZTXDMPARAM_201611291745.csv"
frame1 = pd.read_csv(path1,encoding='utf8',dtype = {'COMPANY_ORGANIZATION': str})

frame1

The output is here

like image 942
tonyibm Avatar asked Nov 09 '22 05:11

tonyibm


1 Answers

I think you can strip column names by value ":

df.columns = df.columns.str.strip('"')

Or if all values contains " use parameter quotechar='"' in read_csv:

like image 81
jezrael Avatar answered Nov 14 '22 22:11

jezrael