home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 383350237

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/pull/2073#issuecomment-383350237 https://api.github.com/repos/pydata/xarray/issues/2073 383350237 MDEyOklzc3VlQ29tbWVudDM4MzM1MDIzNw== 16351486 2018-04-22T02:24:17Z 2018-04-22T02:58:49Z NONE

No, these should not

An example

```python

creat dataframe

index = pd.MultiIndex.from_arrays([['a', 'a', 'b'], [0, 1, 2]], names=['one', 'two']) df = pd.DataFrame({'x': 1, 'y': 2}, index=index)

display

df ```

<table border="1" class="dataframe"> <thead> <tr style="text-align: right;"> <th></th> <th></th> <th>x</th> <th>y</th> </tr> <tr> <th>one</th> <th>two</th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <th rowspan="2" valign="top">a</th> <th>0</th> <td>1</td> <td>2</td> </tr> <tr> <th>1</th> <td>1</td> <td>2</td> </tr> <tr> <th>b</th> <th>2</th> <td>1</td> <td>2</td> </tr> </tbody> </table>

```python

use xr.Dataset transform

xr.Dataset(df) ```

<xarray.Dataset>
Dimensions:  (dim_0: 3)
Coordinates:
  * dim_0    (dim_0) MultiIndex
  - one      (dim_0) object 'a' 'a' 'b'
  - two      (dim_0) int64 0 1 2
Data variables:
    x        (dim_0) int64 1 1 1
    y        (dim_0) int64 2 2 2

```python

use xr.Dataset.from_dataframe transform

xr.Dataset.from_dataframe(df) ```

<xarray.Dataset>
Dimensions:  (one: 2, two: 3)
Coordinates:
  * one      (one) object 'a' 'b'
  * two      (two) int64 0 1 2
Data variables:
    x        (one, two) float64 1.0 1.0 nan nan nan 1.0
    y        (one, two) float64 2.0 2.0 nan nan nan 2.0

From the above example,xr.Dataset.from_dataframe is a better representation of the coordinate than xr.Datasetfrom pandas.dataframe

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  316540429
Powered by Datasette · Queries took 0.819ms · About: xarray-datasette