How to add header row to a pandas DataFrame

后端 未结 4 2049
梦谈多话
梦谈多话 2020-11-28 17:54

I am reading a csv file into pandas. This csv file constists of four columns and some rows, but does not have a header row, which I want to add. I have been try

4条回答
  •  攒了一身酷
    2020-11-28 18:45

    You can use names directly in the read_csv

    names : array-like, default None List of column names to use. If file contains no header row, then you should explicitly pass header=None

    Cov = pd.read_csv("path/to/file.txt", 
                      sep='\t', 
                      names=["Sequence", "Start", "End", "Coverage"])
    

提交回复
热议问题