« first day (3563 days earlier)      last day (1371 days later) » 

5:38 AM
I used pandas to_latex but I 'm getting these strange \$ characters. ibb.co/ngBbjLS
In overleaf I get this ruined ibb.co/X35Qp2R. Any ideas on how to fix this?
dpaste.com/0N9152K latex for you to copy
 
And those $ characters definitely don't exist in your dataframe?
 
ibb.co/vJF8NY2 does this clarify it?
 
:I
Yes and no. You're clearly creating your dataframe with those $ characters in it, so why are you surprised to see them in the latex output?
 
I want to show the dataframe/table in my overleaf editor as I m able to able to see in the jupyter notebook with those subscripts and superscripts. That's the goal. Without those $ I can't create superscripts or subscripts.
$ is an indication that raw string is latex string.
 
5:53 AM
Ok, I don't know overleaf or latex or pandas, so I can't help with that
 
that's fine. I think there are university people here who might be more used to it. I ll wait.
just for the sake of info you can see what happens on removing $ ibb.co/MZcCM2c
 
I mean, yeah, of course pandas doesn't interpret latex markup. It should look correct if you call to_latex on it
actually, maybe not. I'll just shut up now
 
 
1 hour later…
7:14 AM
2
Q: How to prevent pandas.Dataframe.to_latex from adding escape \ characters before latex formula characters (i.e dollar signs/brackets)?

MarsesI'm trying to produce a data table for a paper that I can insert into the LaTeX document, using pandas. However, the entries of both the table headers and the elements need to be mathematical formulas in latex ($...$). In my case, this is because some of them because they have subscripts, and oth...

 
thanks @MisterMiyagi , works like a charm
 
 
3 hours later…
9:57 AM
self.times = defaultdict(lambda : defaultdict(lambda : [0, 0]))
what do you think of that code? why wouldnt you do
self.times = defaultdict(defaultdict([0, 0]))
 
10:15 AM
@Permian the fact that the latter doesn't work is a good enough reason for most people
 
how does it know though that [0, 0] should be a key value pair
 
@Permian that question is not even wrong. Please try harder. After spending 30 minutes playing with those two lines of code in a REPL.
Of course I'm only saying this because of your track record here
You can start with defaultdict(lambda: [0, 0]) and defaultdict([0, 0]) if the double indirection is too hard
 
 
2 hours later…
12:03 PM
cbg-ning
 
cbg
 
 
2 hours later…
2:04 PM
Hey all - I've asked here before regarding dupes. I just got a python badge deserved or not. I'd rather not hammer, I like the voting aspect. Any suggestions?
 
@wwii no, you can only hammer. I suggest hammering when you're at least 50% confident (99% of answerable questions are dupes). With the new follow feature you can be notified by OPs' protests and reopen if necessary.
When in doubt you're always welcome to ask here, but that's slow
 
@AndrasDeak - the follow feature is automatic?
nevermind
 
2:33 PM
Fortunately no :P
 
 
1 hour later…
3:47 PM
has anyone used sympy or some other python library which can calculate latex expressions? I used sympy's parse_expr but got ` File "<string>", line 1
Integer (8 ) \Function ('left' )(Integer (8 ) \Function ('left' )(Float ('4.7' )Symbol ('imes' )Integer (10 )^{-Integer (3 )}Symbol ('rac' ){Integer (240 )}{Float ('.834' )}(Integer (1 ))
^
SyntaxError: unexpected character after line continuation character` error
I just need a way to compute my big expressions for whivh I have already prepared the latex report
 
@VisheshMangla MCVE?
 
Ooh! I think I know this one! I bet you have an invalid character after your line continuation character.
Considering the backslash is the line continuation character, I'm betting you need to escape it.
 
4:05 PM
@wwii congrats on the gold pyhton badge. Hammer away
@CodyGray you're lurking more and more here. I'm pretty sure you secretly wish to learn python
 
@Jean-FrançoisFabre Will I eventually learn it by lurking here? If so, it seems a fair deal. Otherwise, if I have to put in actual effort...
 
what have you tried?
 
Writing C++
 
okay, remove all semi-colons, replace std::vector by list and you're almost there.
 
@Jean-FrançoisFabre he sticks around to bask in his illusion of superiority
 
4:12 PM
C++ is superior to python, no doubt. But it requires a superior level of concentration and masochism that I don't always want to endure.
 
But I like the semicolons. They remind me of you, sir!
 
the worst thing that can happen to you after having developped a super-cool program in python is that a boss says: can you port that on <some embedded system with just a C/C++ compiler>.
@CodyGray lol. Actually you can leave the semicolons in python at start if not putting them makes you unconfortable.
... just us modz trolling C++ in python chatroom... std::cout << "sorry\n";
 
5:07 PM
@Jean-FrançoisFabre - thnx , woohoo
 
6:00 PM
Any idea why this loop doesn't run ? for i in range(0, 1, -1): print("Hello")
this should be an inf loop
 
@VisheshMangla check len(range(0, 1, -1))
hint: you can't get a truly infinite loop with range
Why don't you just use a while loop?
 
ok I will do it with while, actually I opened my python in cmd and wanted to generate a one liner iterator to give me next term of collatz conjecture. I wanted to observe some patterns.
 
@VisheshMangla I asked why you don't just use a while loop and you posted an answer to a question asking "without a while loop".
@VisheshMangla works as expected
 
ok, fine I rather required a logic that why for i in range(0, 1, -1): print("Hello") doesn't work. i should decrease 0, -1, -2, -inf and will never reach 1
 
@VisheshMangla sorry, I can't keep doing this. Good luck.
 
6:46 PM
@VisheshMangla ...no, because your negative one has it stepping by -1 each time. If you go in range(1, 0, -1) it will print 1, if you have range(5, 0, -1) it will print 5,4,3,2,1
 
So I'm writing an app that needs to store oauth access tokens (a "native app" in oauth speak - it runs on the user's PC, not on some web server). What's the recommended way to do this? Is it sane to store tokens in the user's keyring?
 
7:08 PM
Long time cabbages! Sorry for the off-topic here. Just a brief message say hi and hope everyone is doing great! Have been facing some tough months, but the I'm starting to see the sun after weathering the storm. Cheers and I'll be back soon to this room!
 
7:22 PM
Hi everyone, I have one small problem. I have a bar chart in matplotlib where the X-ticks are big strings. When I show them on x-ticks they are tearing out through the graph. I already have tried modifying the figsize of the plot, but that does not help. Can anyone suggest anything?
 
@RishikMani have you tried rotating the ticklabels?
 
@AndrasDeak yes but still they tear out. A tick could be, for example, as long as "farthest shape from circle?"
 
What do you exactly mean by "tear out"? They are only partly visible?
 
yes
 
if you have a small example it might help
you can probably set the figure's size manually to something larger, or set something about the bbox when you export it into a pdf
 
7:30 PM
this is the end result
 
@RishikMani does this also happen interactively or only on export to a file?
 
i havent checked interactively. And what does interactively mean?
 
I mean when you do plt.show() and a figure pops up, versus saving it with fig.savefig or similar. But I'll assume it happens in both cases.
Does fig.tight_layout() help by any chance?
 
yeah happens in both cases
let me try
@AndrasDeak it worsens. Both Y and X cannot be seen
 
ha!
@RishikMani The best option I can find is matplotlib.org/faq/howto_faq.html#howto-subplots-adjust
 
7:42 PM
thank you for your time. I will take a look
 
when I've had crowded figures I always ended up increasing the window size because that was enough for my use cases
setting bottom=0.2 or similar will probably work
As a side note, it seems a bit weird to me that the labels don't end at the corresponding ticks but are centered instead. Corresponding anchoring them differently. I suspect that's easy to do.
 
@AndrasDeak thank you very much again. That resolved the issue.
 
glad to hear that :)
For reference there's an example that adjusts the figure automatically which you can probably repurpose for your xticks. Probably more work, but the result would probably be future-proof.
 
bookmarked the link ;)
 
 
1 hour later…
8:48 PM
I need help figuring out how to manage an aiohttp.ClientSession in my program. Using requests, I had an API like this - a global session that's used for all requests. This isn't possible with aiohttp because the session should be created inside the mainloop, and should be closed before the mainloop exits. Is there a way to swap out requests for aiohttp without having to change the interface? (i.e. no boilerplate like async with Session() for the user of my lib)
First time doing async stuff and I'm already disliking it :/
 
9:10 PM
For my own curiosity, why have you switched?
It sounds a bit like a scoped_session from SQLA but I'm not sure I fully follow. I don't know whether there's anything useful in how that's implemented
 
I need to send some data through a websocket on the side, and the websockets module is async, so I thought I should go full async
 
9:24 PM
FWIW even Flask hasn't done this
 

« first day (3563 days earlier)      last day (1371 days later) »