[英]Filter a Dataframe using a subset of it and two specific fields in spark/scala
[英]scala/spark filter dataframe with multiple conditions using sql
我需要在 upsert 之前過濾 df 。 Df 沒有索引列,並且每一行都不同:
數據框如下所示:
+---+---+---+---+--------+---+
| Col1| Col2| Col3| Col4| Col5|
+---+---+---+---+--------+---+
| Area| null| null| null| null|
| Data| null| XRP 36| null| null|
| 2020-01-02| 2020-01-03| 2020-01-04| 2020-01-05| null|
| SUM | null| null| null| null|
| 0.5 | 0.8| .5| 0.2| 13|
| Area | null| null| null| null|
| Price | null| null| null| null|
| 4000VBG | 4000VBG| 4000VBG| 4000VBG| null|
| Data | null| FDX 45| null| null|
| 2020-02-02 | 2020-02-03| 2020-02-04| 2020-02-05| null|
| SUM | null| null| null| null|
| 0.5 | 0.8| .5| 0.2| 13|
+---+---+---+---+--------+
我需要這樣的 output :
+---+---+---+---+--------+---+
| Col1| Ccol2| Col3| Col4| C5|
+---+---+---+---+--------+---+
| Data| null| XRP 36| null| null|
| 2020-01-02| 2020-01-03| 2020-01-04| 2020-01-05| null|
| 0.5| 0.8| .5| 0.2| 13|
| Data| null| FDX 45| null| null|
| 2020-02-02| 2020-02-03| 2020-02-04| 2020-02-05| null|
| 0.5| 0.8| .5| 0.2| 13|
+---+---+---+---+--------+
所以對於每一行都有“數據”我需要數據、日期和值。
謝謝
嗯。 . . 我想你只是不想not null
:
select t.*
from t
where col2 is not null or col3 is not null or col4 is not null;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.