I want to change a dict entry into a dataframe. Example:
data1 ={'Description': ['Python is an interpreted, high-level and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant whitespace. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.[28]'],
'Site': ['Wikipedia'],
'Categories': ['Python', 'Programming']
}
The output I want is something like this:
Description Site Categories
0 Python is an interpreted, high-level and Wikipedia [Python, Programming]
general-purpose programming language. Python's
design philosophy emphasizes code readability
with its notable use of significant whitespace.
Its language constructs and object-oriented
approach aim to help programmers write clear,
logical code for small and large-scale projects
.[28]
If I do pd.DataFrame.from_dict(data1)
, I get this error
ValueError: arrays must all be same length
in which I fixed by
pd.DataFrame.from_dict(data1,orient='index').transpose()
However, two issues arose:
1st: the description is truncated. Only this portion of the text appears: "Python is an interpreted, high-level and genre..."
2nd: the output is split into two entries as in the image above.
How can I solve these issues?
question from:
https://stackoverflow.com/questions/65887467/dict-into-dataframe-representation-dict-of-list-and-text-entries 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…