Implement `value_counts` method
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Implement value_counts method
MCVE Code Sample
print(object)
<xarray.DataArray (subtissue: 49, sample: 532, gene_id: 31490)>
dask.array<where, shape=(49, 532, 31490), dtype=object, chunksize=(1, 10, 31490), chunktype=numpy.ndarray>
Coordinates:
* gene_id (gene_id) object 'ENSG00000000003' ... 'ENSG00000285966'
* sample (sample) object 'GTEX-1117F' 'GTEX-111CU' ... 'GTEX-ZZPU'
* subtissue (subtissue) object 'Adipose - Subcutaneous' ... 'Whole Blood'
Suggested API:
object.value_count(**kwargs) should return an array with a new dimension defined by the kwargs key, containing the count values of all dimensions defined by the kwargs value.
Expected Output
object.value_count(observation_counts=["subtissue", "sample"])
<xarray.DataArray (observation_counts: 3, gene_id: 31490)>
dask.array<where, shape=(3, 31490), dtype=int, chunksize=(3, 31490), chunktype=numpy.ndarray>
Coordinates:
* gene_id (gene_id) object 'ENSG00000000003' ... 'ENSG00000285966'
* observation_counts (observation_counts) object 'underexpressed' 'normal' 'overexpressed'
Problem Description
Currently there is no existing equivalent to this method that I know in xarray.
Versions
Output of `xr.show_versions()`
INSTALLED VERSIONS
commit: None
python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.3.11-1.el7.elrepo.x86_64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.3
xarray: 0.15.0
pandas: 1.0.0
numpy: 1.17.5
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: 2.4.0
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2.10.1
distributed: 2.10.0
matplotlib: 3.1.3
cartopy: None
seaborn: 0.10.0
numbagg: None
setuptools: 45.1.0.post20200119
pip: 20.0.2
conda: None
pytest: 5.3.5
IPython: 7.12.0
sphinx: 2.0.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the MCVE against current xarray and compare the requested value_counts API with the suggested arguments, dimensions, coordinates, and expected counts. Done means the API and method naming are resolved and the example produces the documented DataArray shape and values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100