Read data in Excel column into Python list

前端 未结 5 1090
囚心锁ツ
囚心锁ツ 2020-12-31 10:16

I am using python xlwings to read a column of data in Excel 2013. Column A is populated with numbers. To import this column into a python list py_list

5条回答
  •  情话喂你
    2020-12-31 10:34

    I found this as the easiest way to create lists from the entire columns in excel and it only takes the populated excel cells. import pandas as pd import numpy as np

    #Insert complete path to the excel file and index of the worksheet
    df = pd.read_excel("PATH.xlsx", sheet_name=0)
    # insert the name of the column as a string in brackets
    list1 = list(df['Column Header 1']) 
    list2 = list(df['Column Header 2'])
    
    print(list1)
    print(list2)
    

提交回复
热议问题