From 6e6849b747d97db9e49d1928ecb8336b737c8819 Mon Sep 17 00:00:00 2001 From: tangchao <735056338@qq.com> Date: Wed, 25 May 2022 23:43:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=BE=93=E5=87=BA=E7=9A=84si?= =?UTF-8?q?f=E5=80=BC=E4=B8=AD=E6=9C=89=E8=B4=9F=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sif_retrieval.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sif_retrieval.py b/sif_retrieval.py index d2242d2..ae53a7e 100644 --- a/sif_retrieval.py +++ b/sif_retrieval.py @@ -183,7 +183,26 @@ def processing(standard_sif, folder, out_file, pars, data, header, sky_p='P1', m _sif = _sif.assign_coords(spec=spec) ls.append(_sif) sif = xr.merge(ls) - sif.to_dataframe().to_csv(out_file) + # sif.to_dataframe().to_csv(out_file) + + tmp_tc = sif.to_dataframe() # tmp_tc是Pandas 数据结构 - DataFrame + cols = tmp_tc.columns + rows = tmp_tc.index + for col in cols: + if str(tmp_tc[col].dtype) == 'object': # 如果是字符串就略过 + continue + for i in range(tmp_tc[col].shape[0]): + if (tmp_tc[col][i] < 0): + tmp_tc.loc[rows[i], col] = 0 + # tmp_tc[col][i] = 0 # 会出错:A value is trying to be set on a copy of a slice from a DataFrame + + # for i in range(tmp_tc.shape[0]): # 行 + # for j in range(tmp_tc.shape[1]): # 列 + # if str(tmp_tc.iloc[i, j].dtype) == 'object': # 如果是字符串就略过 + # continue + # print(tmp_tc.iloc[i, j]) + + tmp_tc.to_csv(out_file)