tonyibm tonyibm - 1 year ago 69
Python Question

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})


The output is here

Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download