Skip to content

Commit 65c1c74

Browse files
committed
adds documentation for DataSource read and context manager
1 parent 1734357 commit 65c1c74

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

docs/source/api/data_source.rst

+37
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,40 @@ DataSource
66
.. autoclass:: pandas_visual_analysis.data_source.DataSource
77
:members:
88
:show-inheritance:
9+
10+
Advanced Usage of DataSource
11+
------------------------------
12+
13+
For getting started see the `basic usage guide <https://pandas-visual-analysis.readthedocs.io/en/latest/#usage>`_.
14+
15+
Read Data
16+
^^^^^^^^^^^
17+
18+
It is possible to read data directly from from files or URLs from the DataSource using default settings.
19+
20+
.. code-block:: python
21+
22+
from pandas_visual_analysis import DataSource
23+
ds = DataSource.read_csv("./mpg.csv")
24+
25+
26+
To infer the file type from the extension use the ``read()`` method. Supported file types are: .csv, .tsv and .json.
27+
28+
.. code-block:: python
29+
30+
from pandas_visual_analysis import DataSource
31+
ds = DataSource.read("./mpg.json", orient="columns")
32+
33+
For more advanced options, use the functionality provided by `Pandas <https://pandas.pydata.org/pandas-docs/stable/reference/io.html>`_
34+
and pass the DataFrame to DataSource normally.
35+
36+
Using DataSource as a context manager
37+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
39+
Instead of assigning the DataSource object to a variable, it is also possible to use it as a context manager.
40+
41+
.. code-block:: python
42+
43+
from pandas_visual_analysis import DataSource, VisualAnalysis
44+
with DataSource.read("./report.tsv", header=1) as ds:
45+
VisualAnalysis(ds)

docs/source/api/visual_analysis.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ VisualAnalysis
88
:show-inheritance:
99

1010

11-
Advanced Usage
12-
----------------
11+
Advanced Usage of VisualAnalysis
12+
----------------------------------
1313

1414
For getting started see the `basic usage guide <https://pandas-visual-analysis.readthedocs.io/en/latest/#usage>`_.
1515

0 commit comments

Comments
 (0)