home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

4 rows where issue = 316540429 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: reactions, created_at (date), updated_at (date)

user 3

  • DansYU 2
  • shoyer 1
  • max-sixty 1

author_association 2

  • MEMBER 2
  • NONE 2

issue 1

  • recommend xr.Dataset.from_dataframe(df) instead of xr.Dataset(df) for… · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions performed_via_github_app issue
383364259 https://github.com/pydata/xarray/pull/2073#issuecomment-383364259 https://api.github.com/repos/pydata/xarray/issues/2073 MDEyOklzc3VlQ29tbWVudDM4MzM2NDI1OQ== DansYU 16351486 2018-04-22T08:21:20Z 2018-04-22T08:21:20Z NONE

When I am a novice, I want to convert multidimensional data of pd.Dataframe into xr.Dataset. The 'Multi-dimensional data' section is found from the 'Working with pandas' chapter. Then, I skipping the other to this section. this example showed that Xarray is not good at Multi-dimensional data until i discovered xr.Dataset.from_dataframe

i know the mean of the leading paragraph, but it may be obstacles in this the 'Multi-dimensional data' section for novices.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  recommend xr.Dataset.from_dataframe(df) instead of xr.Dataset(df) for… 316540429
383355977 https://github.com/pydata/xarray/pull/2073#issuecomment-383355977 https://api.github.com/repos/pydata/xarray/issues/2073 MDEyOklzc3VlQ29tbWVudDM4MzM1NTk3Nw== shoyer 1217238 2018-04-22T05:10:17Z 2018-04-22T05:10:17Z MEMBER

I agree that from_dataframe should be preferred -- which is exactly why we mention in first on this doc page.

I'm not sure this change makes sense, since the leading paragraph introduces this example with "Both the DataArray and Dataset constructors..."

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  recommend xr.Dataset.from_dataframe(df) instead of xr.Dataset(df) for… 316540429
383350237 https://github.com/pydata/xarray/pull/2073#issuecomment-383350237 https://api.github.com/repos/pydata/xarray/issues/2073 MDEyOklzc3VlQ29tbWVudDM4MzM1MDIzNw== DansYU 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
}
  recommend xr.Dataset.from_dataframe(df) instead of xr.Dataset(df) for… 316540429
383348212 https://github.com/pydata/xarray/pull/2073#issuecomment-383348212 https://api.github.com/repos/pydata/xarray/issues/2073 MDEyOklzc3VlQ29tbWVudDM4MzM0ODIxMg== max-sixty 5635139 2018-04-22T01:51:08Z 2018-04-22T01:51:08Z MEMBER

Should these return the same result?

{
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  recommend xr.Dataset.from_dataframe(df) instead of xr.Dataset(df) for… 316540429

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
);
CREATE INDEX [idx_issue_comments_issue]
    ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
    ON [issue_comments] ([user]);
Powered by Datasette · Queries took 1535.456ms · About: xarray-datasette