You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> To make projection on top of non-mapping values (like custom objects), use
144
144
> the `.apply()` approach.
145
145
146
+
## Dropping Columns
147
+
Similarly to projections, you may drop unnecessary columns from incoming records using a `StreamingDataFrame.drop()` method.
148
+
149
+
It accepts either one column name as a string or a list of names.
150
+
151
+
The `.drop()` method updates the existing `StreamingDataFrame` object and returns the same `StreamingDataFrame` instance so that you can chain other methods after the `drop()` call, too.
152
+
153
+
Internally, it mutates the record's value and deletes the keys in place.
154
+
155
+
**Example**:
156
+
157
+
In this example, assume you receive temperature readings in the following format:
158
+
159
+
```json
160
+
{
161
+
"temperature": 35.5,
162
+
"timestamp": 1710865771.3750699,
163
+
"metadata": {
164
+
"sensor_id": "sensor-1"
165
+
}
166
+
}
167
+
```
168
+
169
+
and you need to drop a "metadata" key from the record:
170
+
171
+
```json
172
+
{
173
+
"temperature": 35.5,
174
+
"timestamp": 1710865771.3750699
175
+
}
176
+
```
177
+
178
+
Here is how to do that with `StreamingDataFrame`:
179
+
180
+
```python
181
+
sdf = app.dataframe(...)
182
+
# Dropping the "metadata" key from the record's value assuming it's a dictionary
183
+
sdf.drop("metadata")
184
+
185
+
# You may also drop multiple keys by providing a list of names:
186
+
sdf.drop(["metadata", "timestamp"])
187
+
```
188
+
189
+
> **_NOTE:_** The `StreamingDataFrame.drop()` method works only with mapping-like values like dictionaries.
0 commit comments