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

Wide repr formatting problem #2585

Closed
wesm opened this issue Dec 22, 2012 · 8 comments
Closed

Wide repr formatting problem #2585

wesm opened this issue Dec 22, 2012 · 8 comments
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Milestone

Comments

@wesm
Copy link
Member

wesm commented Dec 22, 2012

Bummer. This happened in IPython on git master, display.line_width set to 80

In [18]: df.columns
Out[18]: Index([Symbol, Description, MTM MTD, MTM YTD, Realized ST MTD, Realized ST YTD, Realized LT MTD, Realized LT YTD, Underlying, Kind], dtype=object)

In [19]: df
Out[19]: 
  Symbol Description  MTM MTD  MTM YTD  Realized ST MTD  Realized ST YTD  Realized LT MTD  Realized LT YTD Underlying Kind
0    NaN         NaN      NaN      NaN              NaN              NaN              NaN              NaN        NaN  NaN
1    NaN         NaN      NaN      NaN              NaN              NaN              NaN              NaN        NaN  NaN
2    NaN         NaN      NaN      NaN              NaN              NaN              NaN              NaN        NaN  NaN
3    NaN         NaN      NaN      NaN              NaN              NaN              NaN              NaN        NaN  NaN
4    NaN         NaN      NaN      NaN              NaN              NaN              NaN              NaN        NaN  NaN
@changhiskhan
Copy link
Contributor

It's not breaking the line?

I can't seem to repro on OSX or Ubuntu; i have line_width set to 80

@wesm
Copy link
Member Author

wesm commented Dec 25, 2012

I'm able to reproduce it but not using the above example. i'll dig to figure out what's up

@wesm
Copy link
Member Author

wesm commented Dec 25, 2012

OK the IPython check is failing for me:

In [12]: com.in_interactive_session()
Out[12]: False
In [1]: import pandas.core.common as com

In [2]: com.in_interactive_session()
Out[2]: True

It appears that using %run to execute a script changes the __main__ module to look like a non-interactive session:

In [1]: import pandas.core.common as com

In [2]: com.in_interactive_session()
Out[2]: True

In [3]: run ib_stmt.py

In [4]: com.in_interactive_session()
Out[4]: False

We should fix this along with a few other little buglets and cut 0.10.1 later this week

@changhiskhan
Copy link
Contributor

@wesm
Copy link
Member Author

wesm commented Dec 28, 2012

@minrk what is the appropriate way to find out if we're inside an interactive IPython session?

@changhiskhan
Copy link
Contributor

Here's my current solution:

def check_main():
    import __main__ as main
    return (not hasattr(main, '__file__') or
            get_option('mode.sim_interactive'))

try:
    return __IPYTHON__ or check_main()
except:
    return check_main()

@wesm
Copy link
Member Author

wesm commented Dec 28, 2012

thanks, looking good. we can always tweak if one of the IPython guys has a better way

@wesm wesm closed this as completed Dec 28, 2012
@minrk
Copy link
Contributor

minrk commented Dec 29, 2012

I typically use the NameError test, but with get_ipython. __IPYTHON__ was added back in, so there could be a way that would work on both sides of the 0.10-0.11 transition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

3 participants