![](/img/trans.png)
[英]What's the best way(error proof / foolproof) to parse a file using python with following format?
[英]What is the best way to get the following data into long format using column labels?
numpy中的解決方案:
arr = np.array([[1., 0., 0.], [1., 0., 0.], [0., 0.,1.], [0.,1.,0.]])
names = ['age01', 'age02', 'age03']
val = [float(names[ind][4:6]) for ind in np.where(arr == 1.)[1]]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.