flat_table
flat_table copied to clipboard
Bug when expanding dataframe
Trying to expand a dataframe:
expanded_df = flat_table.normalize(df, expand_lists=True, expand_dicts=True)
I got a bad shape after expanded_df
My df structure is like this:
| Intents | Clean_Description | Clean_Short_Description | Algorithm | System | Is_ata | Language | ShortDescription | Description |
|---|---|---|---|---|---|---|---|---|
| [] | v | v | Intent_similarity | ISA | FALSE | en | v | v |
| [] | d | c | Intent_similarity | ISA | FALSE | en | c | d |
| [{'Prediction': 'Intent2094', 'Similarity_score': 0.6559049986732967, 'Threshold': 0.5, 'Confident': True, 'Closest_email_ID': '10301533'}] | f | a | Email_similarity | APA | FALSE | en | a | f |
But the output is only one row well formatted, but only one row, the one which has the list inside
What's wrong with my code?
I am sorry for the late reply, @RNogales94. If it is still useful, I figured what's wrong with the data frame.
For lists or dicts to expand, they need to be deserialized for flat_table to work. You need to use literal_eval to convert df.Intents to python list. I made a notebook for it. You can check it out.
Hope this helps.