Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Other datasets #3

Closed
scls19fr opened this issue Mar 1, 2016 · 0 comments
Closed

Other datasets #3

scls19fr opened this issue Mar 1, 2016 · 0 comments

Comments

@scls19fr
Copy link

scls19fr commented Mar 1, 2016

Hello,

you can, if you want, use one of these datasets
https://github.com/Rdatasets/python

  • titanic: Survival of passengers on the Titanic
  • hair_eye_color: Hair and Eye Color of Statistics Students

data are taken from R core datasets
but code is mine.

It can probably be useful for a tutorial about xarray.
It can also probably be useful to compare R and Python.

see my issue about mosaic plot pydata/xarray#779

It could also help to improve how DataArrays display.

See for example in R:

> HairEyeColor
, , Sex = Male

       Eye
Hair    Brown Blue Hazel Green
  Black    32   11    10     3
  Brown    53   50    25    15
  Red      10   10     7     7
  Blond     3   30     5     8

, , Sex = Female

       Eye
Hair    Brown Blue Hazel Green
  Black    36    9     5     2
  Brown    66   34    29    14
  Red      16    7     7     7
  Blond     4   64     5     8

and using Python/xarray

In [1]: import hair_eye_color
In [2]: hair_eye_color.data
Out[2]:
<xarray.DataArray 'Freq' (Sex: 2, Eye: 4, Hair: 4)>
array([[[32, 53, 10,  3],
        [11, 50, 10, 30],
        [10, 25,  7,  5],
        [ 3, 15,  7,  8]],

       [[36, 66, 16,  4],
        [ 9, 34,  7, 64],
        [ 5, 29,  7,  5],
        [ 2, 14,  7,  8]]])
Coordinates:
  * Sex      (Sex) <U6 'Male' 'Female'
  * Eye      (Eye) <U5 'Brown' 'Blue' 'Hazel' 'Green'
  * Hair     (Hair) <U5 'Black' 'Brown' 'Red' 'Blond'

Kind regards

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants