为了账号安全,请及时绑定邮箱和手机立即绑定

从 for 循环输出连接大数据框 Python

从 for 循环输出连接大数据框 Python

慕标琳琳 2021-09-14 15:50:53
我正在尝试根据每个 for 循环输出的切片结果构建一个大数据集。我所做的代码如下:for n in range(4):     script_dir = os.path.dirname(directory)    rel_path = files[n]    abs_file_path = os.path.join(script_dir, rel_path)    to_open = pd.read_csv(abs_file_path, header=0)    to_open["Geographic Address"] = to_open["Geographic Address"].astype(str)    to_open["Geographic Address"] = to_open["Geographic Address"].map(lambda x: x[3:-1])    to_open = to_open[to_open["Geographic Address"] == ld_up[n]]    to_open.index = range(len(to_open))    ind = np.searchsorted(to_open["Time"], time[n])    ind = np.asscalar(np.array(ind))    UpperBound = ind - 30    data = to_open.iloc[UpperBound:ind,:]如您所见,从数据列中,如果我对输出进行切片,则仅显示案例 3 的输出,我想要一个大文件,同时包含案例 0、1、2、3。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 288 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号