Skip to content Skip to sidebar Skip to footer

What Is The Best Way To Extract This Data

Looking at the site, i suppose not to see an error because each local language(Yoruba) as it Meaning and Translation, and there are 220 local language(Yoruba). from bs4 import Beau

Solution 1:

Since each of the three keys has different length, I guess the best way to address it is to pad the short keys to the length of the longest key (220, in this case). To do that add the following right before creating your dataframe:

length = max(len(edu['Meaning']),len(edu['Translation']),len(edu['Yoruba'])) #in case you don't know, find the length of the longest keyfor k in edu:
    for i inrange(length-len(edu[k])):
        edu[k].append("NA") # this is where the padding is; you can replacing NA with anything else, obviously

df7 = pd.DataFrame.from_dict(edu) #since edu is a dictionary, I would use this method
df7

Let me know if that works.

Post a Comment for "What Is The Best Way To Extract This Data"