I have a dictionary that I want to convert into DataFrame, the problem I'm having is my dictionary is in the following format:
sample_dict = {'test':['test string',['feature1','feature2', 'feature3']]}
When trying to convert using something like
df = pd.DataFrame.from_dict([sample_dict])
I get:
What I'm trying to achieve is something like:
Any ideas?
CodePudding user response:
Add orient
out = pd.DataFrame.from_dict(sample_dict, orient='index')
Out[287]:
0 1
test test string [feature1, feature2, feature3]
CodePudding user response:
Can use from_records
as well.
df = pd.DataFrame.from_records(d).T
0 1
test test string [feature1, feature2, feature3]