Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/source/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -902,14 +902,14 @@ For instance:

.. ipython:: python

set_eng_float_format(precision=3, use_eng_prefix=True)
set_eng_float_format(accuracy=3, use_eng_prefix=True)
df['a']/1.e3
df['a']/1.e6

.. ipython:: python
:suppress:

set_printoptions(precision=4)
reset_printoptions()


The ``set_printoptions`` function has a number of options for controlling how
Expand Down
13 changes: 13 additions & 0 deletions doc/source/dsintro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,24 @@ For very large DataFrame objects, only a summary will be printed to the console
(here I am reading a CSV version of the **baseball** dataset from the **plyr**
R package):

.. ipython:: python
:suppress:

# force a summary to be printed
print_config = core.common.GlobalPrintConfig
core.common.GlobalPrintConfig.max_rows = 5

.. ipython:: python

baseball = read_csv('data/baseball.csv')
print baseball

.. ipython:: python
:suppress:

# restore GlobalPrintConfig
core.common.GlobalPrintConfig = print_config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the paraphrased words of Inigo Montoya (from the Princess Bride), "I donna think this does what you think it does" ;) the print_config object is modified. I just fixed this in master, no worries

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, they are both changed of course. So basic, but i stumble on it from time to time ... grr


However, using ``to_string`` will return a string representation of the
DataFrame in tabular form, though it won't always fit the console width:

Expand Down
26 changes: 17 additions & 9 deletions doc/source/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ to do as before:
df = read_csv('foo.csv', parse_dates=True)
df.index

.. ipython:: python
:suppress:

os.remove('foo.csv')


Reading DataFrame objects with ``MultiIndex``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -196,6 +201,12 @@ Automatically "sniffing" the delimiter
comma-separated) files. YMMV, as pandas uses the Sniffer_ class of the csv
module.

.. ipython:: python
:suppress:

df[:7].to_csv('tmp.sv', sep='|')
df[:7].to_csv('tmp2.sv', sep=':')

.. ipython:: python

print open('tmp2.sv').read()
Expand All @@ -211,22 +222,13 @@ Iterating through files chunk by chunk
Suppose you wish to iterate through a (potentially very large) file lazily
rather than reading the entire file into memory, such as the following:

.. ipython:: python
:suppress:

df[:7].to_csv('tmp.sv', sep='|')
df[:7].to_csv('tmp2.sv', sep=':')

.. ipython:: python

print open('tmp.sv').read()
table = read_table('tmp.sv', sep='|')
table

.. ipython:: python
:suppress:

os.remove('tmp.csv')

By specifiying a ``chunksize`` to ``read_csv`` or ``read_table``, the return
value will be an iterable object of type ``TextParser``:
Expand All @@ -248,6 +250,12 @@ Specifying ``iterator=True`` will also return the ``TextParser`` object:
reader = read_table('tmp.sv', sep='|', iterator=True)
reader.get_chunk(5)

.. ipython:: python
:suppress:

os.remove('tmp.sv')
os.remove('tmp2.sv')

Writing to CSV format
~~~~~~~~~~~~~~~~~~~~~

Expand Down