« first day (3346 days earlier)      last day (1586 days later) » 

12:18 AM
very unmotivated to work right now. But there's gonna be skiing this weekend. And of course that's when I found a paper about using quantum sampling to estimate function values, which I now want to use for hyperparameter estimation
 
 
2 hours later…
2:02 AM
@KieranMoynihan NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO, kill it, with fire.
 
 
3 hours later…
5:43 AM
pandas.read_json fails if you don't serialize the input. Both the question and the answer aren't great.
As to What is deserialize and serialize in JSON?, it's a good question from 2010 and needs a canonical, but there is one offtopic answer discussing pickle, two deleted answers (one spamlink, one Java), one okay answer and only one good answer. Someone might like to edit/ post a better answer (also it seems SO now displays answers in totally random order regardless of votecounts(?), which makes this worse...)
 
 
1 hour later…
6:57 AM
Another question: I did some heavy surgery to rewrite "Conditionally assign keys in dict" to what it really wanted Convert pandas dataframe to dict to JSON, unflatten nested subkeys, drop None/NaN keys. But what's the recommended function to unflatten nested subkeys 'c.x', 'c.y', 'c.z' into a subdict?
...there are 10 questions on [python] unflatten dict, which one is best esp. for JSON? (i.e. also inlines dropping None keys)
@αԋɱҽԃαмєяιcαη That shouldn't be slow, pandas does ok at csv export/import. How many rows and columns? Were any columns complex python objects? Please post a question with reproducible example (random-seeded data is fine).
@AndrasDeak Actually pandas does ok. I've never found read_csv performance to be that bad in 10 years using it. (Unicode, serialization, other stuff, sure, but never performance. Sure, it's always faster to write custom parsers for objects). I don't use to_csv much though - waiting for @αԋɱҽԃαмєяιcαη's testcase
@αԋɱҽԃαмєяιcαη also I didn't find any issues listed in pandas github issues. So if you caught something, let's investigate.
 
7:45 AM
ccbg
 
8:02 AM
 
whats this?
 
@Aqua4 I guess it's their Advent of Code leaderboard podium?
 
yea I remember solving these last time
 
for the leaderboard on the side
 
@smci That's not a Python question; at least, it doesn't have a Python tag. BTW, you can choose to order answers by age, activity, or votes.
@AnttiHaapala Unfortunately, Kieran doesn't have that option: he has to use Python 2 for work.
 
9:06 AM
hi
can someone help me here? pastebin.com/byKS7tPd
Im trying to retrace back the printed result into the edges list
and replace the initial edge nodes with the ones that have been labaled with '$' sign
So then my edges will become: [('1$', '2'), ('2', '3$'), ('2', '4'), ('4', '5'),
('5', '2$')]. Note that I want to annotate only the cycles discovered previously
 
9:30 AM
@PM2Ring I know... arson is still an option... I guess having been forced to use Python 2 would count among extenuating circumstances...
 
@AnttiHaapala Possibly... :D
 
9:46 AM
@MikaelKen Maybe, but it would help if you told us explicitly what the code is supposed to do. BTW, I'm pretty sure that Pastebin can do Python syntax colour highlighting. I think you just need to give the file a .py extension, but I haven't used it for a while.
I probably can't offer much help right now because I've got a headache. But others may be lurking...
 
@PM2Ring It's a language-agnostic question. Hadn't even noticed it wasn't tagged Python but it doesn't matter much and one of the answers is Pythonic. Anyway I stil say it's a decent dupe-target for that. If you agree please VtC, if you disagree please show me a better target.
 
@smci just kill the question with fire.
it is a typo and no one can find it...
 
@smci Sorry, I don't know Pandas. But I agree with DSM's comment: that data isn't JSON, it's a repr of a Python list of dicts, so it should be parsed using ast.literal_eval.
 
10:15 AM
@smci I strongly disagree that that language-agnostic JSON question is a suitable dupe target in this case, since the Pandas question doesn't have JSON data. I've been looking for a decent dupe target, but I haven't had much luck. Maybe stackoverflow.com/questions/42631097/… is ok.
 
10:28 AM
I would like to point out that the initial Q title did properly represent the problem (a "JSON" including the illegal Python bool/none values). The new title obfuscates this needlesly.
 
@PM2Ring Python: converting a list of dictionaries to json. You really don't need ast.literal_eval to convert a list of dicts to JSON.
 
that's not what he said, nor what the initial Q was about. The issue is parsing a string representation of Python types to actual Python types.
the only reason that JSON is relevant for the Q is that the OP erroneously tried to parse their data as JSON.
 
10:45 AM
@MisterMiyagi Yes I noticed, so either way the OP's question statement was wrong and needed editing one way or the other (a "JSON" including the illegal Python bool/none values is kind of a strange phrasing). What do you think a better title is? It isn't valid JSON, but the OP wants to kludge it to work pd.read_json.pd.read_json` gives dataframe output whereas ast.literal_eval doesn't.
 
as some of the comments said, the output of ast.literal_eval can be fed to a dataframe.
 
@MisterMiyagi It's apparently some illegal JSON-like thing produced by some other (Python) code.
 
@smci As per the last time we had this "discussion", I would recommend sticking to the original title.
 
'stringified Python object'
 
pardon?
 
10:50 AM
The question is closed, you already downvoted the answer (or at least left a comment saying it was wrong). Nothing needs editing or changing
If the OP chooses to clarify the problem, it's on them to do the edits to clear up what they intended to ask. There's no point guessing for them
 
@MisterMiyagi Ah. I didn't bother looking at the edit history. Confusing JSON with the repr of a Python list of dicts etc is fairly common, so I was surprised that I couldn't find a more accurate dupe target. OTOH, Google is heavily biased towards questions (& especially their titles), so it's very hard to find dupe targets via keywords in the answer, like ast.literal_eval
 
My best friend is back over from Australia. After ticking the Christmas Markets box yesterday, today's plans have oddly been revised from the planned "hike" and pub lunch. I'm surprised how quickly she forgot the weather over here, being battered by the cold wind and rain while they're currently in a heat wave
 
@MisterMiyagi Neither I nor the OP were aware it was definitively not valid JSON, it would have been easier to clearly say so and why; I had read DSM's comment but it didn't state categorically that it wasn't valid. If I had known Please no need to be so abrasive; the unclear OP title and statement generate confusion one way or the other; in this case by trying to kludge it through pd.read_json. Either way it needs some edit: ...
 
@roganjosh I suspect the OP has little interest in their question from 5 years ago. ;)
 
... There are lots of confused questions that try to interpret various types of stringified Python objects as JSON.
 
10:59 AM
@PM2Ring Oh, point taken. I have a bad habit of skipping dates when questions get raised in here and just focus on the content. Oops
 
@smci I would prefer not to repeat the "discussion" we had last time. Suffice to say, I personally see no justification for me to edit a post if I personally have doubts about understanding said post properly.
 
@PM2Ring That's irrelevant. Many ongoing other questions ask similar things. Look at the other questions trying to import JSON. I thought it was useful to identify some of the less bad ones.
@MisterMiyagi And neither do I. But in this case I believed it to be valid JSON because a) nobody definitively said "this isn't valid JSON" and b) the OP was saying that pd.read_jsonwas the right thing to do. The most important missing thing about the to-and-fro on that question was that noone ever clearly said "This isn't valid JSON; it's stringified Python". That's the missing part.
@roganjosh Yes, there are various such questions from 2010-current.
^ ... until PM2Ring finally posted that 45min ago.
 
I know there are, which is why I'm not invested in this singular one in the slightest. 1K views over 5 years
 
@roganjosh Possibly it should have been napalmed. I was interested in it if it had a useful reference answer for future questions. But no
 
@smci Huh? Of course it's relevant. We can't expect the OP to be involved in the curation of that question (their last post was in February of this year), we probably have to do it without their further input.
 
11:08 AM
@PM2Ring What's the correct thing then to do with an old confusingly-worded/titled question whose OP is not responding, yet which can't be deleted since it has an answer, albeit not a great one? Tell me what you guys usually do with those.
(Logging off for tonight)
 
@smci I'm happy with the current state of that question. Hopefully it'll help future readers with similar confusions.
 
@PM2Ring The final state of that one is ok. But there's still lots of ongoing confusion about what is and isn't JSON vs stringified Python representation. Which leads to people trying to use str() or json.dumps() in the wrong ways.
 
11:36 AM
Am I correct in thinking then that we have rods because criticality depends on 3D dimensions and you can "cheat" by extending in 1 dimension (from Would a uranium 235 fuel pellet the size of Earth explode?)
 
12:19 PM
@roganjosh Sort of. Yes, a slender rod has a much greater critical mass than a sphere, all other things being equal. Reactor design is a complicated business, but Wikipedia has some great articles that give plenty of details without getting too technical. FWIW, I just posted a comment on that question:
That's an awful lot of uranium! Using the abundance data here, I estimate that you'd have to extract all the uranium from around 25,000 stellar systems of equivalent mass to our solar system. — PM 2Ring 5 mins ago
 
@PM2Ring This answer actually reminded me of high school physics where our physics teacher said that a uranium bomb was like two coconut shells being blasted together. Criticality never really made much sense to me but I got a bit of a lightbulb moment reading that. Then again, I know you raise and lower carbon rods in reactors so there is interaction between rods. I'll do some research
 
I don't want to start a big conversation here about fission reactors, but one of the key things is neutron moderation. See en.wikipedia.org/wiki/Neutron_moderator
 
>I don't want to start a big conversation here about fission reactors
why not though
 
12:36 PM
@Unihedron Well, it is the Python room. :) A little bit of non-Python stuff is ok, especially during slow times, but nuclear physics is a big topic, and such discussions can end up being rather large. But we have discussed such stuff here in the past
We had a fun discussion about radioactive waste a while ago, starting around here: chat.stackoverflow.com/transcript/6?m=45911165#45911165
 
1:19 PM
Is there a way to "force" a set to change order from your input? A question has just reminded me that I'm now doing weekly sessions trying to teach the IT dept about Python and every simple example I picked actually came out ordered whilst trying to demo the issue
 
1:57 PM
@roganjosh Small sets of integers are often ordered. I think that's because for integers that fit in a machine word, hash(n) == n, (apart from n == -1). I wrote an answer about this a couple of years ago, I'll see if I can find it.
 
I tried a mixed set of strings and ints too, but they were also small because I was typing it all out.
 
See my demo code here: stackoverflow.com/a/51578541/4014959 The other answers there are worth reading too. :)
 
ugh. I must have been dreaming that I tried something I didn't. Maybe I did all ints and all strings, but not a combination.
 
2:13 PM
@Unihedron cool figure
 
than k you
 
Advent of Code makes me want to change my avatar to Turbo the racing snail :)
@Unihedron what plotting library did you use to make that?
 
It's a chrome extension for private leaderboard advanced stats
 
3:09 PM
^ closed, thanks
 
4:02 PM
@smci yeah, I was mostly commenting on importing pandas just so that someone might import a csv.
 
4:44 PM
recbg
 
 
4 hours later…
8:15 PM
Can anyone help me get a python cgi script running in Apache2
I have created a file "cgi-enabled.conf" at /ect/apache2/conf-available and put the following in it:
# create new
# process .cgi and .py as CGI scripts

<Directory "/var/www/html/master.com">
  Options + ExecCGI
  AddHandler cgi-script .cgi .py
</Directory>
Where /var/www/html/master.com/test.py is the file I want to run. I have also run a2enmod cgi and have tried restarting Apache2 twice
 
8:48 PM
If I have a pandas dataframe indexed by date, is there a simple way to multiindex it where the first index is year-month and the second index is day? For context, I'm trying to do a fixed effect regression where theres a fixed effect for each year-month
 
if I knew pandas I imagine an MCVE would help
at least runnable input; I understand what you want to end up with
 
9:07 PM
I think I figured it out, I did this: pastebin.com/phVtTuRg
 
9:34 PM
Friday: Stayed up til 6am reading Beastars
Saturday: Started reading Houseki no Kuni at 10 PM
Sunday: Sleep schedule will be broken beyond repair, probably
 
you could've done AoC live after Friday ;)
 
hah, I said I'd rather work on my stuff than do AoC and I ended up writing exactly 0 lines of code
so yeah, maybe I could've done AoC
 
9:57 PM
you still can :)
 
 
2 hours later…
11:52 PM
@Aran-Fey did you see the anime adaptation of Land of the Lustrous?
 
Yeah. I looked it up yesterday after I finished Beastars, and realized that was all the way back in '17. So I gave up on waiting for season 2 and now I'm reading the manga
page 473/1960... this is gonna take a little longer than 6am
 

« first day (3346 days earlier)      last day (1586 days later) »