Python 创建.xlsx文件单列元素列表

Python 创建.xlsx文件单列元素列表,python,python-3.x,xlsx,Python,Python 3.x,Xlsx,我遇到了一个问题:我试图在.xlsx文件的一列中创建一个浮动列表。我有一个索引器:元组索引超出范围 x = [] wb=load_workbook('sample_data1(dynamics).xlsx') ws = wb.active columnX = ws['L'] for i in range(len(columnX)): if columnX[i+1].value != '-': %Just because in some cells of this column I

我遇到了一个问题:我试图在.xlsx文件的一列中创建一个浮动列表。我有一个
索引器:元组索引超出范围

x = []

wb=load_workbook('sample_data1(dynamics).xlsx')
ws = wb.active
columnX = ws['L']

for i in range(len(columnX)): 
    if columnX[i+1].value != '-': %Just because in some cells of this column I have '-'
        x.append(float(columnX[i+1].value)) 
当我尝试其他版本的代码时:

x = []

wb=load_workbook('sample_data1(dynamics).xlsx')
ws = wb.active
columnX = ws['L']

for i in range(len(columnX)): 
    if columnX[i].value != '-' or columnX[i].value != 'Point of Regard Right X [px]': %Just because first cell contain 'Point of Regard Right X [px]'
        x.append(float(columnX[i].value)) 

我有以下错误:
ValueError:无法将字符串转换为float:“考虑点右X[px]

那么,有人能帮我吗?

熊猫(带xlrd)通常会帮我做以下事情:

import pandas
df = pandas.read_excel('sample_data1(dynamics).xlsx')
col = 'REQUIRED COL'
col_values_list = list(df[col])
pandas将处理将值转换为浮点值的操作。

pandas(带xlrd)通常为我完成以下操作:

import pandas
df = pandas.read_excel('sample_data1(dynamics).xlsx')
col = 'REQUIRED COL'
col_values_list = list(df[col])

pandas将处理值到浮点值的转换。

您所说的所需列是什么意思?就我一个人?然后,我有一个“KeyError:”L“,这是列名。您可以使用“打印(df.columns)”检查“已识别”列。我不能确定为什么在没有看到xlsx文件的情况下出现此错误,您所说的必需列是什么意思?就我一个人?然后,我有一个“KeyError:”L“,这是列名。您可以使用“打印(df.columns)”检查“已识别”列。我无法确定为什么在没有看到xlsx文件的情况下出现此错误