[英]python convert string list into a dataframe list
I have a list of string dataframes that I want to turn into a list of dataframes.我有一个字符串数据帧列表,我想将其转换为数据帧列表。
temp_df = {}
temp_df['mdf1'] = df1[df1['b']<=0.4]
temp_df['mdf2'] = df1[df1['a']<=0.58]
def get_list(temp_df):
return [*temp_df]
temp_list = get_list(temp_df)
temp_list
Doing this I get the stringed list:这样做我得到了字符串列表:
output: ['mdf1', 'mdf2']
However, I also want a list of the two dataframes itself.但是,我还想要一个包含两个数据框本身的列表。 For the desirable output of:
对于理想的 output 的:
output: [mdf1, mdf2]
I've tried this but it doesn't give me what I want:我试过这个但它没有给我我想要的东西:
temp_df.keys()
output: dict_keys(['mdf1', 'mdf2'])
Check with locals
then然后
locals
variables = locals()
variables["mdf1"] = df1[df1['b']<=0.4]
variables["mdf2"] = df1[df1['a']<=0.58]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.