Bernardo Furtado
Bernardo Furtado

Reputation: 13

reading excel files in pandas - columns with NaN header

I am trying to read this excel sheet: https://1drv.ms/x/s!AkiO0urKs8OwgSDHRD2IoE4LPBtt with pandas(python)

#!/usr/bin/python

# -*- coding: latin-1 -*-

import os, sys   
import urllib2    
from collections import Counter    
import json    
from pprint import pprint 
import pandas as pd  
from pandas import ExcelWriter   
from pandas import ExcelFile
import numpy as np   
import pandas as pd    
import matplotlib.pyplot as plt

file_name = "test.xlsx"

df = pd.read_excel(file_name, sheetname='Resultados 1 fase')

print df

I am trying to get the match results by index, for example:

1 - 1   x   0

2 - 2   x   2

3 - 0   x   2

4 - 4   x   0

...

But when I see the result of the code above many column headers are NaN and I don't know how to extract the information I need from. Can anyone help me with this?

Thanks

Upvotes: 1

Views: 744

Answers (1)

zipa
zipa

Reputation: 27889

This should give you the desired output:

df = pd.read_excel('test.xlsx', skiprows=3, header=None, parse_cols='F:H')

Upvotes: 1

Related Questions