Python Pandas ValueError Arrays Must be All Same Length

前端 未结 5 1263
终归单人心
终归单人心 2020-12-14 02:15

Iterates over a big list of .mp3 links to get the metadata tags and save it to an Excel file. Results in this error. I appreciate any help. Thanks.

    #pri         


        
5条回答
  •  我在风中等你
    2020-12-14 02:51

    You can pad the shortest lists with empty elements:

    def pad_dict_list(dict_list, padel):
        lmax = 0
        for lname in dict_list.keys():
            lmax = max(lmax, len(dict_list[lname]))
        for lname in dict_list.keys():
            ll = len(dict_list[lname])
            if  ll < lmax:
                dict_list[lname] += [padel] * (lmax - ll)
        return dict_list
    

提交回复
热议问题