DOC: add doc for reading from DataFrame.to_html by cpcloud · Pull Request #3656 · pandas-dev/pandas (original) (raw)

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation38 Commits2 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

cpcloud

@jreback

@cpcloud

just added more notes, so yep

@jreback

dont' use assert_frame_equal in the v0.11.1...instead print out the table
I would not use df_list, maybe alist or something (you note that the return type is a list is good and would leave that in though)
e.g. alist[0] (or alist[0].head()) if its too long

@jreback

perfect!

fyi....since its ipython, the print is not necessary....

@cpcloud

cool. i figured. pre-ipdb debugging habits die hard!

@jreback

hmm....can you rebase on top of master?

@cpcloud

Yeah sorry. Will do when I get to a machine...

@cpcloud

@cpcloud

@jreback

@cpcloud

yep saw it i'm on it, i'm getting a different error locally about recursion depth...

@cpcloud

prolly cause i changed the default of infer types...and thus everything is evil object arrays

@cpcloud

@jreback any changes to assert_frame_equal recently? not made by me...

@cpcloud

ugh why does assert a == b, "%s != %s" % (a, b) not cause a recursion error but assert a == b, "{0} != {1}".format(a, b) does?!

@jreback

I think @y-p changed something...didn't seem to affect me

(btw you can NOT have it compare dtypes, there is an option)

but I think you should have infer_dtypes=True by default, it makes sense
(or at least maybe do floats/ints by default), even dates really
people can always turn it off

@cpcloud

ok...the example of reading in the output of df.to_html() will fail because DataFrame(['a']).convert_objects(convert_dates='coerce') thinks 'a' is a date. i will just use soft conversion then

@jreback

yeh...dates are tough (though coerce will only convert if at least 1 item is a date)......(if all are not dates then it will leave it)

@cpcloud

wait but why is 'a' considered a date?

@jreback

what is in the series? a (alone) shouldn't trigger it

@cpcloud

if u just do

s = Series(['a']).convert_objects(convert_dates='coerce')

s now has a date. I think this is a bug...

@cpcloud

note new date conversion behavior

jreback doc recommendations

cannot pass a string to to_thml

gah

working notes

modify tests

infer_types back to true as per disc. with @jreback

fix failing tests because of not correctly converted dates

weird recursion error when using format spec instead of format strings

@jreback

evil! I can see 'today' being parsed to today, but a????

(Pdb) import dateutil
(Pdb) dateutil.parser.parse('a')
datetime.datetime(2013, 5, 21, 0, 0)

@cpcloud

@cpcloud

ah yes when parsers become too powerful and take over the world! mwahaha!

@cpcloud

it's because 'a' is a token for 'am'

@cpcloud

and also the default of just returning the current time kicks in since the parse of 'a' returns None.

@cpcloud

kind of insane if u ask me...

@jreback

a,m,p,t are the offenders (I check them all now).....so odd, you would think you could turn this option off

@jreback

@jreback

ok...merging.....after my PR you can decide if you want to turn convert_dates back on (or even make it a separate option to read_html)

jreback added a commit that referenced this pull request

May 21, 2013

@jreback

DOC: add doc for reading from DataFrame.to_html

@cpcloud cpcloud deleted the read-html-to-html-doc branch

May 22, 2013 02:07

@jreback

@cpcloud if u have a chance
can u do a pr for read/write html in main docs (your read examples in v0.11.1 are prob good start)
at some point want to go thru the options that u allow a bit more in a doc example

and I don't think any docs for to_html

thxs

@cpcloud

@jreback btw should the to_* collection of methods allow str in the buf argument (a file name)? i'm surprised that no one has raised this yet...

@cpcloud

maybe someone has and there's a reason for not supporting it...i haven't looked through issues for it

@jreback

as far as I know these methods should accept path_or_buf
may not be consistent

@cpcloud

ok i will open a pr for any inconsistencies i find with that

@cpcloud

@jreback would u mind if i show the html output as rendered html in the examples? that way a user gets the final result and doesn't have to open up browser to see the rendered html...

@jreback

@cpcloud

hm how do u feel about a bunch of html files in a subdirectory of source? don't think there's any thing like a context manager for sphinx

@jreback

I think you can put what you need in doc/source/_static; this is how the .png get read in the plotting docs

@jreback

as an example, I do this is io.rst (for showing how to read a legacy file)

    .. ipython:: python
        :suppress:

        import os
        legacy_file_path = os.path.abspath('source/_static/legacy_0.10.h5')

     .. ipython:: python

        # a legacy store
        legacy_store = HDFStore(legacy_file_path,'r')
        legacy_store

        # copy (and return the new handle)
            new_store = legacy_store.copy('store_new.h5')
            new_store
        new_store.close()

2 participants

@cpcloud @jreback