ktl014
7/21/2017 - 10:10 PM

reading in column labels, deleting columns From https://stackoverflow.com/questions/24901766/python-how-to-get-column-names-from-pandas-data

# print out column labels of dataframe
names = df.columns.values 

# delete column
#  1 is the axis number (0 for rows and 1 for columns.)
df = df.drop('column_name',1)

# delete column without having to reassign df
df.drop('column_name', axis=1, inplace=True)

# drop by column number instead of by column label, try this to delete, e.g. the 1st, 2nd and 4th columns:
df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index 
Cov = pd.read_csv("path/to/file.txt", sep='\t', 
                  names = ["Sequence", "Start", "End", "Coverage"])

# alternative option of reading in csv and adding to columns                  
Cov = pd.read_csv("path/to/file.txt", sep='\t', header=None)
Cov.columns = ["Sequence", "Start", "End", "Coverage"]