好的,我要做的是用python列出一个列表。将其传递给函数或for循环,这样就可以使用列表的条目作为新列表的名称。你知道吗
所以如果我有
items = [buckets, lemons, carrots]
我想做:
for item in items:
item = [1,2,3,4,len(item)]
举个简单的例子。你知道吗
我真正需要做的是我有一个csv文件,其中有一堆列。对于每个列,我需要在目标名称中交叉引用列名和集合名。(csv有6000列)。所以设计是:
foods = [banana, taco, seasoning, avacado]
imported = thecsvfile.csv #already imported this is just an example
def targetgrab(targets, data):
for item in targets:
for col in data.columns:
if item = col:
item = data.columns[col]
targetgrab(foods,imported)
希望输出
banana = [item1, 2, 3,...,x,y,z]
taco = [item1, 2, 3,...,x,y,z]
seasoning = [item1, 2, 3,...,x,y,z]
avacado = [item1, 2, 3,...,x,y,z]
然后,这些输出被传递到一个设备上,该设备使用我从中提取的特定列中的信息。在这种情况下我不能使用字典(我以前也用过),我宁愿不用拆开字典并从字典中创建列表。这将只是杂乱无章,加上约5秒的处理设备,我正在使用。考虑到我衡量的是依赖于时间的事物,这是至关重要的。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐