Skip to content
Merged
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6163f32
@TomNicholas
harshitha1201 Mar 16, 2023
f5ffd8e
Merge branch 'pydata:main' into main
harshitha1201 Mar 16, 2023
f54e331
Merge branch 'pydata:main' into main
harshitha1201 Mar 20, 2023
0d18d56
commit 1
harshitha1201 Mar 20, 2023
ae572bb
@TomNicholas please review
harshitha1201 Mar 20, 2023
711afb7
Merge branch 'main' of https://github.com/harshitha1201/xarray
harshitha1201 Mar 20, 2023
035b55d
@TomNicholas please review
harshitha1201 Mar 20, 2023
a436bda
latest commit
harshitha1201 Mar 21, 2023
b7bbcea
Changes done on formatting the code
harshitha1201 Mar 21, 2023
6d2573e
pre-commit bot changes
harshitha1201 Mar 21, 2023
0e3e23f
code changes
harshitha1201 Mar 21, 2023
40f37a6
commit_check
harshitha1201 Mar 21, 2023
791fe93
formatted function names
harshitha1201 Mar 21, 2023
59cfb7d
passed all checks
harshitha1201 Mar 21, 2023
c0cf6c4
checks_commit
harshitha1201 Mar 22, 2023
e9aa032
changes done_added zarr
harshitha1201 Mar 22, 2023
3b34b32
Merge branch 'pydata:main' into main
harshitha1201 Mar 23, 2023
f5a2165
Merge branch 'main' of https://github.com/harshitha1201/xarray
harshitha1201 Mar 22, 2023
48f2ab8
minor changes
harshitha1201 Mar 23, 2023
e475a53
Merge branch 'pydata:main' into main
harshitha1201 Mar 24, 2023
6e052a4
documentation changes
harshitha1201 Mar 24, 2023
e0a3835
Merge branch 'main' of https://github.com/harshitha1201/xarray
harshitha1201 Mar 24, 2023
08f6233
Merge branch 'pydata:main' into main
harshitha1201 Mar 24, 2023
9c35aa8
ready for review
harshitha1201 Mar 24, 2023
1299df1
Merge branch 'main' of https://github.com/harshitha1201/xarray
harshitha1201 Mar 24, 2023
509ae80
added what I have done to whats-new.rst
harshitha1201 Mar 26, 2023
ae43b04
updated
harshitha1201 Mar 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions doc/getting-started-guide/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,99 @@ What other projects leverage xarray?
------------------------------------

See section :ref:`ecosystem`.

How do I open format X file as an xarray.Dataset?
-------------------------------------------------

To open format X file in xarray, you need to know the `format of the data <https://docs.xarray.dev/en/stable/user-guide/io.html#csv-and-other-formats-supported-by-pandas/>`_ you want to read. If the format is supported, you can use the appropriate function provided by xarray. The following table provides links to the functions for different file formats in xarray, as well as links to other packages that can be used:

.. csv-table::
:header: "File Format", "xarray Backend", " Other Packages"
Comment thread
harshitha1201 marked this conversation as resolved.
Outdated
:widths: 15, 35, 15

"NetCDF (.nc, .nc4, .cdf)","xarray.open_dataset() OR xarray.open_mfdataset()", "`netCDF4 <https://pypi.org/project/netCDF4/>`_, `netcdf <https://pypi.org/project/netcdf/>`_ , `cdms2 <https://cdms.readthedocs.io/en/latest/cdms2.html>`_"
Comment thread
harshitha1201 marked this conversation as resolved.
Outdated
"HDF5 (.h5, .hdf5)","xarray.open_dataset() OR xarray.open_mfdataset()", "`h5py <https://www.h5py.org/>`_, `pytables <https://www.pytables.org/>`_ "
"GRIB (.grb, .grib)", "xarray.open_dataset()", "`cfgrib <https://pypi.org/project/cfgrib/>`_, `pygrib <https://pypi.org/project/pygrib/>`_"
"CSV (.csv)","xarray.open_dataset()<br>xarray.open_mfdataset()","`_pandas <https://pandas.pydata.org/>`_ , `dask <https://www.dask.org/>`_ "
"JSON (.json)","xarray.open_dataset()","`json <https://docs.python.org/3/library/json.html>`_, `.pandas <https://pandas.pydata.org/>`_"

To use these backend functions in xarray, you can simply call them with the path to the file(s) you want to read as an argument.
Comment thread
harshitha1201 marked this conversation as resolved.
Outdated

NetCDF
Comment thread
harshitha1201 marked this conversation as resolved.
------
Use xarray.open_dataset() to open a NetCDF file and return an xarray Dataset object.

.. code:: python

import xarray as xr

# Use forward slashes(/), while mentioning the file location
Comment thread
harshitha1201 marked this conversation as resolved.
Outdated
# use xarray to open the file and return an xarray.Dataset object
ds = xr.open_dataset('/path/to/my/file.nc', engine='netcdf4')

# Print Dataset object
print(ds)

HDF5
----
Comment thread
harshitha1201 marked this conversation as resolved.
Outdated
Use xarray.open_dataset() to open an HDF5 file and return an xarray.Dataset object.

.. code:: python

import h5netcdf
Comment thread
harshitha1201 marked this conversation as resolved.
Outdated
import xarray as xr

# Open HDF5 file as an xarray Dataset
ds = xr.open_dataset('path/to/hdf5/file.hdf5', engine='h5netcdf')

# Print Dataset object
print(ds)


We recommend you to install h5netcdf library using

.. code:: python

pip install h5netcdf

GRIB
-----------
use the xarray.open_dataset() function from the cfgrib package to open a GRIB file as an xarray Dataset.

.. code:: python

import xarray as xr

# define the path to your GRIB file and the engine you want to use to open the file
# use xr.open_dataset to open the file with the specified engine and return an xarray.Dataset object
ds = xr.open_dataset('path/to/your/file.grib', engine='cfgrib')

# Print Dataset object
print(ds)

We recommend installing cfgrib via conda:
.. code:: python

conda install -c conda-forge cfgrib

CSV
---
.. code:: python

import xarray as xr
import
as pd

# Load CSV file into pandas DataFrame using the "c" engine
df = pd.read_csv('your_file.csv', engine='c')

# Convert pandas DataFrame to xarray.Dataset
ds = xr.Dataset.from_dataframe(df)

#Prints the resulting xarray dataset
print(ds)

Some packages may have additional functionality beyond what is shown here. You can refer to the documentation for each package for more information.

How should I cite xarray?
-------------------------
Expand Down