The tab file I\'m working with is missing the final column name. When I attempt to repair the header by appending the missing value, I get a mismatch error. Here\'s an exa
The problem was the argument index_col=0 was beginning column indexing at the gene names:
The above dataframe ended at 2073, which with 1-based indexing with the above argument, was 2073 elements: one element fewer than my repaired header. This generated the following error:
ValueError: Length mismatch: Expected axis has 2073 elements, new values have 2074 elements
While the same read_csv command with index_col=None assigned a separate numerical index, putting the (in this case gene names) back into the dataframe from being just labels:
The above dataframe ended at the column number 2073, which is 2074 elements with zero-based indexing: the same length as my repaired header! Problem solved: