python - How to exclude first word in Pandas header? -
i'm importing text files pandas data frames. number of columns can vary , names varies.
however, header line starts ~a
, read_csv interprets s name of first column, subsequently column names shifted on step right.
earlier used np.genfromtxt()
argument deletechars = 'a__'
haven't find equivalent function pandas. there way exclude name when reading or, second option, delete first name keep columns intact?
i'm reading file this:
in_file = pd.read_csv(file_name, header=header_row,delim_whitespace=true)
now got (just text file looks):
~a depth time tx1 tx2 tx3 out6 11705 2.94 10525.38 126.14 169.71 353.86 4.59 nan 11706 2.93 10525.38 nan 168.29 368.00 4.75 nan 11707 2.92 10525.38 126.14 166.71 369.86 4.93 nan
but want' this:
depth time tx1 tx2 tx3 out6 11705 2.94 10525.38 126.14 169.71 353.86 4.59 11706 2.93 10525.38 nan 168.29 368.00 4.75 11707 2.92 10525.38 126.14 166.71 369.86 4.93
why not post-process?
df = ... df_modified = df[df.columns[:-1]] df_modified.columns = df.columns[1:]
Comments
Post a Comment