Open cocopops17 opened 1 year ago
In short: it may be possible, but it looks to be pretty involved, if so.
Stata's pystata api doesn't allow for it. So we'd have to try the completely separate route of Stata Automation that stata_kernel
uses--and I'm not sure that separate approach can be made to play nicely with pystata
.
To confirm my understanding, are you using Windows, or MacOS? If Windows, you did that extra install step for stata_kernel
, right?
Currently, I'm only vaguely familiar with how this part of stata_kernel
works, so it would be a steep climb for me to attempt adding this functionality personally. I'd be quick to pull it in if someone else codes it, though.
Another possibility would be to petition StataCorp to add this functionality to pystata
, but I'm not sure they will see that as in their interest.
I'd also really like to have this feature. In practice, I myself currently go back and forth between working in Jupyter Lab and the normal Stata application, largely to be able to use browse
. As long as the data you're working with isn't too big, it is relatively quick to save a .dta file in the notebook and then open it in normal Stata. But it would be really nice to streamline that workflow further somehow.
%head
and %tail
should work for you, at least, though I recognize they are nowhere near the same. (Another imperfect substitute: there may be a way to get nbstata
's %browse plug-in to work with Atom, maybe starting from here, but that's definitely beyond my own aspirations.)
This is also my biggest gripe with using Jupyter Notebooks for Stata with the current pystata API, which prevents me from fully embracing the workflow for exploratory analysis. @hugetim inspired by your call for petition, I posted this on Statalist.
In the meantime, I had experimented with various third-party data viewers for Python and I believe the best one is D-Tale. Would it ever be possible to have something like this integrated into %browse
magic?
Great, I'll go upvote you on Statalist!
And thanks for finding D-Tale! I think that looks better (and much easier to install) than the thing I had been using, so I expect I'll replace that with this very soon.
Ok, I spent several hours trying to get D-tale to work reliably, and I couldn't. (And that's not even considering the difficulties campus folks would have trying to get it to work on JupyterHub.) Instead, I'm going with a much simpler and more robust option in ipydatagrid.
But I'm thinking to add a %%python magic (someday) that would let you access dtale on your own if you want..
I tried the new %browse magic in v0.5.0 and I like the fact that it's plain and requires no other packages to be installed. However, I experience sluggishness on my MacBook M1 (Safari). Please see the screen capture. Is this normal? I'd expect it to be buttery smooth as it's seemingly a very simple applet.
Also, two minor questions: Would it be possible to have an option to move this to a separate window (as in Data Editor in Stata)? And is it possible to change the font within the view (from Courier to something else)?
Right click on it in JupyterLab and select "Create New View for Output." That gives you a separate tab within JupyterLab. But if you meant moving it to a separate browser tab, I don't know if that's possible.
On the sluggishness, I wasn't able to replicate that, trying it just now, so I'm not sure what to suggest. There's no sluggishness for me (albeit on a powerful Windows desktop, using Chrome).
I'm reluctant to change the default font because that's deliberately matching Stata's default look. I could make it configurable if that's important to you though. I guess maybe it's easier to see long strings with a different font?
This is what I see on classic Notebook:
There is no way to resize that browse
window.
Then I switch to Lab. Datagrid looks fine, but the choppiness is real (mind you this is the tiny auto
dataset):
I'm on M1 Mac with macOS Monterey and Safari so I don't know if this is specific to Apple setup.
As a workaround while we try to address those issues, you can use %head [N]
or %tail [N]
as an alternative to %browse
(replacing [N]
with a number at least as large as your observation count). That should give you output equivalent to pystata_kernel
's %browse magic.
Is it possible to get "browse" to work as it did with stata_kernel (i.e. open Stata's native browser in a new window)? I'm still using the Hydrogen package in Atom to run my code, so the currently-implemented %browse magic doesn't work for me.