[英]NetCDF4 file with Python - Filter before dataframing
您可以使用sel
來過濾您的數據集:
import pandas as pd
import xarray as xr
import datetime
# Load a demo dataset
ds = xr.tutorial.load_dataset('air_temperature')
# Keep only 12:00 rows
df = ds.sel(time=datetime.time(12)).to_dataframe()
Output:
>>> df
air
lat time lon
75.0 2013-01-01 12:00:00 200.0 242.299988
202.5 242.199997
205.0 242.299988
207.5 242.500000
210.0 242.889999
... ...
15.0 2014-12-31 12:00:00 320.0 296.889984
322.5 296.589996
325.0 295.690002
327.5 295.489990
330.0 295.190002
[967250 rows x 1 columns]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.