<jupyter_start><jupyter_text>Adding functionality so we can create dataframe from string representation of dict<jupyter_code>import ast
def str_to_dict(string):
    return ast.literal_eval(string) 
import pandas as pd
class MySubClass(pd.DataFrame):
    def from_str(self, string):
        df_obj = super().from_dict(str_to_dict(string))
        df_obj.my_string_attribute = string
        return df_obj
data = "{'col_1' : ['a','b'], 'col2': [1, 2]}"
obj = MySubClass().from_str(data)
type(obj)
obj
obj.my_string_attribute
sales = [{'account': 'Jones LLC', 'Jan': 150, 'Feb': 200, 'Mar': 140},
         {'account': 'Alpha Co',  'Jan': 200, 'Feb': 210, 'Mar': 215},
         {'account': 'Blue Inc',  'Jan': 50,  'Feb': 90,  'Mar': 95 }]
df = MySubClass(sales)
df
type(df)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.165, 'fraction_numerical': 0.035, 'mean_word_length': 4.5625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '853', 'license': 'MIT', 'n_tokens_mistral': 320, 'n_tokens_neox': 285, 'n_words': 75, 'path': '6_a_extending_dataframe_capabilities.ipynb', 'repo_name': 'mj111312/pandas_basics', 'size': '800'}