Pandas Get a List Of All Data Frames loaded into memory

前端 未结 3 523
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-09 19:01

I am using pandas to read several csv files into memory for processing and at some point would like to list all the data frames I have loaded into memory. Is there a simple

3条回答
  •  盖世英雄少女心
    2020-12-09 19:43

    building on previous answers ... this returns a list

    import pandas as pd 
    %who_ls DataFrame 
    

    however, if you try to run a script it doesn't work

    thus

    import pandas as pd
    sheets=[]    
    for var in dir():
        if isinstance(locals()[var], pd.core.frame.DataFrame)  and var[0]!='_':
            sheets.append(var)
    

    since some DataFrames will have a copy for internal use only and those start with '_'

提交回复
热议问题