Skip to content

Commit

Permalink
Merge pull request #85 from Crunch-io/update-create-docs-188545853
Browse files Browse the repository at this point in the history
Update create dataset example
  • Loading branch information
rchacon1 authored Nov 12, 2024
2 parents 9bb0733 + dbb2950 commit bff59de
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ each Tuple in a catalog's index, which follows the link to the Entity resource:
}
})

### Creating a New Dataset

You typically add new resources to a Catalog via its `create` method:

>>> ds = site.datasets.create({"body": {
'name': "My first dataset"
}}, refresh=True)
"name": "My first dataset",
"project": "https://your-domain.crunch.io/api/projects/dbf9foo7b727/"
}})
>>> ds.refresh()
>>> gender = ds.variables.create({"body": {
'name': 'Gender',
'alias': 'gender',
Expand All @@ -143,15 +147,37 @@ You typically add new resources to a Catalog via its `create` method:
{'id': 2, 'name': 'F', 'numeric_value': None, 'missing': False}
],
'values': [1, 2, {"?": -1}, 2]
}}, refresh=True)
>>> print(ds.table.data)
}})
>>> print(ds.table.metadata)
pycrunch.elements.JSONObject(**{
"e7f361628": [
1,
2,
{"?": -1},
2
]
"dbebef213d3d413398f0c4075acb05a7": {
"alias": "gender",
"name": "Gender",
"type": "categorical",
"description": "",
"notes": "",
"derived": false,
"categories": [
{
"missing": true,
"numeric_value": null,
"id": -1,
"name": "No Data"
},
{
"missing": false,
"numeric_value": null,
"id": 1,
"name": "M"
},
{
"missing": false,
"numeric_value": null,
"id": 2,
"name": "F"
}
]
}
})

To access a Pandas Dataframe of the data in your dataset:
Expand Down

0 comments on commit bff59de

Please sign in to comment.