Using read_excel with converters for reading Excel file into Pandas DataFrame results in a numeric column of object type

前端 未结 3 842
囚心锁ツ
囚心锁ツ 2020-12-21 16:16

I am reading this Excel file United Nations Energy Indicators using the code snippet here:

def convert_energy(energy):
    if isinstance(energy, float):
             


        
3条回答
  •  攒了一身酷
    2020-12-21 17:14

    try using isinstance(energy, int) instead of isinstance(energy, float).

    like this->

    def convert_energy(energy):
        if isinstance(energy, int):
             return float(energy*10^6)
    

提交回复
热议问题