[英]Converting Data of string-formatted, Image and Label to list / numpy array
[英]Is there a way to use a string from a list as the label for an array?
我有以這種格式作為列表提供給我的數據:
['NAME', 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0]
我想要做的是將其轉換為具有以下格式的數組:
NAME=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0]
有沒有辦法用代碼來做到這一點,還是我最好手動標記一些數組並將數據附加到它們?
你可以使用字典:
# suppose that l is your list
my_data = {l[0]: l[1:]}
稍后在代碼中,您可以使用:
my_data['NAME']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.