Skip to content
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ from pydataset import data
```python
titanic = data('titanic')
```
- To display the documentation of a dataset:
- To get the documentation of a dataset instead:
```python
data('titanic', show_doc=True)
data('titanic', get_doc=True)
```
- To see the available datasets:
```python
Expand Down Expand Up @@ -59,6 +59,13 @@ For example,

### Changelog

**Forked version**

- changed show_doc parameter to get_doc
- get_doc now returns the documentation as a string
- added new datasets
- removed unnecessary csv files from resources

**0.2.0**

- Add search dataset by name similarity.
Expand Down
14 changes: 7 additions & 7 deletions pydataset/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# __init__.py
# main interface to pydataset module

from .datasets_handler import __print_item_docs, __read_csv, __datasets_desc
from .datasets_handler import __print_item_docs, __read_csv, __datasets_desc, __get_item_docs
from .support import find_similar


def data(item=None, show_doc=False):
def data(item=None, get_doc=False):
"""loads a datasaet (from in-modules datasets) in a dataframe data structure.

Args:
item (str) : name of the dataset to load.
show_doc (bool) : to show the dataset's documentation.
get_doc (bool) : to get the dataset's documentation instead.

Examples:

>>> iris = data('iris')


>>> data('titanic', show_doc=True)
>>> data('titanic', get_doc=True)
: returns the dataset's documentation.

>>> data()
Expand All @@ -27,9 +27,9 @@ def data(item=None, show_doc=False):

if item:
try:
if show_doc:
__print_item_docs(item)
return
if get_doc:
# __print_item_docs(item)
return __get_item_docs(item)

df = __read_csv(item)
return df
Expand Down
8 changes: 6 additions & 2 deletions pydataset/datasets_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ def __get_doc_path(item):
return docs[item]


def __print_item_docs(item):
def __get_item_docs(item):
path = __get_doc_path(item)
doc = __read_docs(path) # html format
txt = __filter_doc(doc) # edit R related txt
return __filter_doc(doc) # edit R related txt


def __print_item_docs(item):
txt = __get_item_docs(item)
print(txt)


Expand Down
Binary file modified pydataset/resources.tar.gz
Binary file not shown.