From b5f795c2cc4c80013fe17472d56399dd064e0ef5 Mon Sep 17 00:00:00 2001 From: wangfeng Date: Wed, 1 Feb 2023 21:42:49 +0800 Subject: [PATCH] =?UTF-8?q?#I6CCA7:dataframe=E5=AE=9E=E7=8E=B0FillNa?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataframe_fillna.go | 10 ++++++++++ dataframe_test.go | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 dataframe_fillna.go diff --git a/dataframe_fillna.go b/dataframe_fillna.go new file mode 100644 index 0000000..9665cf2 --- /dev/null +++ b/dataframe_fillna.go @@ -0,0 +1,10 @@ +package pandas + +// FillNa dataframe实现FillNa +func (self DataFrame) FillNa(v any, inplace bool) { + for _, series := range self.columns { + if series.Len() > 0 { + series.FillNa(v, inplace) + } + } +} diff --git a/dataframe_test.go b/dataframe_test.go index 3283c08..f1ef073 100644 --- a/dataframe_test.go +++ b/dataframe_test.go @@ -17,6 +17,8 @@ func TestDataFrameT0(t *testing.T) { s2 := s1.Shift(-2) df := NewDataFrame(s1, s2) fmt.Println(df) + df.FillNa(0.00, true) + fmt.Println(df) _ = s2 } -- Gitee