且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从一列中的唯一值创建Pandas DataFrames

更新时间:2021-11-10 21:43:06

您的当前迭代每次运行都会覆盖x两次:for循环将客户名称分配给x,然后分配一个数据框

Your current iteration overwrites x twice every time it runs: the for loop assigns a customer name to x, and then you assign a dataframe to it.

要稍后能够按名称调用每个数据框,请尝试将它们存储在字典中:

To be able to call each dataframe later by name, try storing them in a dictionary:

df_dict = {name: df.loc[df['customer name'] == name] for name in customerNames}

df_dict['Name3']