I am assigning column names to a dataframe in pandas but the column names are creating new columns how do I go around this issue?
What dataframe looks like now:
abs_subdv_cd abs_subdv_desc 0 A0001A ASHTON ... NaN 1 A0002A J. AYERS ... NaN 2 A0003A NEWTON ALLSUP ... NaN 3 A0004A M. AUSTIN ... NaN 4 A0005A RICHARD W. ALLEN ... NaN What I want dataframe look like:
abs_subdv_cd abs_subdv_desc 0 A0001A ASHTON 1 A0002A J. AYERS 2 A0003A NEWTON ALLSUP 3 A0004A M. AUSTIN 4 A0005A RICHARD W. ALLEN code so far:
import pandas as pd ###Declaring path### path = ('file_path') ###Calling file in folder### appraisal_abstract_subdv = pd.read_table(path + '/2015-07-28_003820_APPRAISAL_ABSTRACT_SUBDV.txt', encoding = 'iso-8859-1' ,error_bad_lines = False, names = ['abs_subdv_cd','abs_subdv_desc']) print(appraisal_abstract_subdv.head()) -edit-
When I try appraisal_abstract_subdv.shape..the dataframe is showing shape as (4000,1) where as the data has two columns.
this example of data I am using:
A0001A ASHTON A0002A J. AYERS Thank you in advance.