python - convert float string to numpy array with different rows -


इस सवाल का पहले से ही एक उत्तर है: < / p>

  • 3 उत्तर

    मेरे पास स्ट्रिंग अंतिम_लाइन जैसा

      0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0130631958731,0.0,0.0,0.0,0.0,0.0,0.0,0.0130631958731,0.0,0.0, 0.0,0.0,0.0,0.0, 0.00507937313707,0.0,0.0,0.0,001058520009,0.0,0.0,0.0459562331449,0.0268078026679,0.0,0.0103772139359,0.0,0.0,0.0438673134565,0.0,0.0268078026679,0.0,0.0,0.0,0.0,0.0,0.0224437417685 , 0.0,0.0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,070802847389,0.0,0.0 ,, 0.0,0.0,0.169140135429 , 0.0,0.0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0.0,0.0,0,0,0,0,0,0,0,0,0,0, 0.0,0.0261263917462,0.0,0.0,0.0,0.0,0.0,0.0,0.0261263917462,0.0,0.0,0.0,0.0,0.0,0.0, 0.0961428138228,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0.0 , 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0 .0,0.0,   

    मैं इसे CSV फ़ाइल को स्थानांतरित किए बिना उसे नोडी सरणी में कनवर्ट करना चाहता हूं। यहां स्ट्रिंग में प्रत्येक पंक्ति को अलग-अलग पंक्ति में परिवर्तित किया जाना चाहिए जैसा कि

      [['0', '0', '0', '0', '0', '0', '0 '0', '0', '0', '0.08364751'], ['0.017944717', '0', '0', '0', '0.009470823', '0', '0', '0 '0', '0', '0'], ['0.012620501', '0', '0', '0', '0', '0', '0', '0', '0 ',' 0 ',' 0 '], [' 0.012620501 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 '], [' 0 ',' 0 ',' 0 ',' 0 ',' 0.01332164 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 '], [' 0.012620501 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 '], [ '0', '0', '0', '0', '0', '0.097414177', '0.0420 92545', '0', '0', '0', '0'], ['0' '0', '0', '0', '0.01332164', '0', '0', '0', '0', '0', '0'], ['0.005324215', '0' '0', '0.04598186', '0.028100025', '0', '0', '0', '0', '0', '0.023525603'], ['0', '0', '0' '0', '0', '0', '0', '0', '0.055765006', '0', '0'], ['0', '0', '0.133216404', '0' '0', '0', '0', '0', '0', '0', '0']]   

    मुझे पता है कि अलग-अलग मानों का उत्पादन होता है लेकिन मेरे पास है सिर्फ प्रारूप पाने के लिए दिखाया गया

    उदाहरण

    मेरे पास स्ट्रिंग है जैसा

      a1, b1, c1, d1, e1, a2, b2, c2, d2, e2, a3, b3, c3, d3, e3,  , , , , , 

      [['a1', 'b1', 'c1', 'd1', 'e1'], ['a2', 'b2' , 'सी 2', 'डी 2', 'ई 2'], ['ए 3', 'बी 3', 'सी 3', 'डी 3', 'ई 3']]   <पी> मैंने देखा है अन्य प्रश्न, लेकिन यह सरणी की केवल एक पंक्ति में परिवर्तित हो जाता है उदाहरण के रूप में दिखाया गया है कि मैं यहां हर पंक्ति को नई पंक्ति में चाहता हूं।   

    नक्शा इस मामले में उपयोगी हो सकता है इसके अलावा, अंतिम , आपके अंतिम सूची में जरूरी नहीं है, इसलिए मैं इसे अनदेखा करता हूं (: - 2 से पहले split ऑपरेशन)।

      np के रूप में आयात करें np A = final_line [: - 2] .split (',') B = np.array ([मानचित्र (फ्लोट, ए। ए के लिए विभाजित (','))]    

Comments

Popular posts from this blog

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -

jasper reports - How to center align barcode using jasperreports and barcode4j -

django - CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False -