Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible display several dataframes side by side ? #24

Open
dragosbo opened this issue Oct 9, 2017 · 5 comments
Open

is it possible display several dataframes side by side ? #24

dragosbo opened this issue Oct 9, 2017 · 5 comments

Comments

@dragosbo
Copy link

dragosbo commented Oct 9, 2017

Hi

I was wondering if there is a way to use your package to display several data frames side by side in a jupyter notebook cell. kind of being able to replicate the powepoint slides from this youtube video

https://www.youtube.com/watch?v=9d5-Ti6onew

thanks in advance
Dragos

@epmoyer
Copy link
Owner

epmoyer commented Oct 10, 2017

Hi Dragos!

I think the best approach is to just write a little function that puts each table into a cell of another (invisible) table. You can get the HTML representation of an IpyTable object by calling its .repr_html() method.

The function multi_table() below accepts a list of tables, calls .repr_html() on each to get their HTML, shoves each one into the cell of a vanilla html table, and renders the resulting blob of html using the HTML() function from IPython.core.display.

You should be able to control the formatting (cell spacing, etc) by modifying the code to add more style properties etc. to the html of the outer table.

Cheers!

from IPython.core.display import HTML

def multi_table(table_list):
    ''' Acceps a list of IpyTable objects and returns a table which contains each IpyTable in a cell
    '''
    return HTML(
        '<table><tr style="background-color:white;">' + 
        ''.join(['<td>' + table._repr_html_() + '</td>' for table in table_list]) +
        '</tr></table>'
    )

mutli_table1

mutli_table2

@dragosbo
Copy link
Author

dragosbo commented Oct 10, 2017 via email

@richlysakowski
Copy link

I am trying to use this solution but there is no module named add_parent_to_path.

Is this is a custom module that the author implemented? A wide search in google finds no modules by that name.

@theAfricanQuant
Copy link

This is great. I just used it on my dataframes.

Thanks

@denmanorwat
Copy link

Thank you for your function. Works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants