« first day (4017 days earlier)      last day (1155 days later) » 

00:08
Okay did some more editing https://pastebin.com/LtkFsDXQ no matter what direction I input I get the same output "Play again soon
You are in the Foyer
Enter your move:"
01:01
@Aeroangel now that the code runs, print rooms['Master Bedroom'] in main and see if what you get matches your expectations
Hello Andras
Sup Dog
Not sure if you are free to help, just quickly please, what do you think are most advanced features of pandas besides grouoby please?
I just want to limit myself to learn few things about pandas in Python
groupby turned out to be very compelx indeed! I wrote a problem 4 days ago, which still to this moment find it very difficuly to grasp
@Avra no, it's 3 AM and I'm going to bed
01:04
:(
And I'm still not a pandas user
Sorry, gn
Got it
@Aeroangel lines 53-55 have multiple bugs. We can continue tomorrow.
What's more useful pandas or numpy?
I want to decide what to learn next
 
1 hour later…
02:26
I've been learning python and posting projects to my git hub but idk what to do next
 
4 hours later…
06:05
@SurpriseDog Depends on where you want to go. I'd take pure numpy if number crunching is your focus, and pandas if general data processing is what you're after. But there isn't really a clear-cut line between the two.
Hey people!
I have a doubt regarding grouping in DataFrame (pandas)
Code:
import pandas as pd

Q = {"Item Category":["TV","Smartphone","Fridge","TV","Fridge",
                      "Washing Machine", "Smartphone","Mixer Grinder",
                      "AC","Smartphone","Mixer Grinder"],
     "Item Name":["Sony X80J","Samsung Galaxy Fold 3","LG GL-D201APZX",
                  "Samsung Q60A","LG GL-D201ASPZ","LG THD18STB",
                  "Apple iPhone 13","Preethi Taurus 750W",
                  "Blue Star EBTU","Samsung Galaxy M51",
                  "Preethi Zodiac 750W"],
Output:
      Item Category              Item Name  Expenditure
0                TV              Sony X80J        82900
1        Smartphone  Samsung Galaxy Fold 3       149999
2            Fridge         LG GL-D201APZX        15390
3                TV           Samsung Q60A        66990
4            Fridge         LG GL-D201ASPZ        17790
5   Washing Machine            LG THD18STB        63890
6        Smartphone        Apple iPhone 13        79900
7     Mixer Grinder    Preethi Taurus 750W         8465
In tot, why is Expenditure position a bit weird?
Please tag me when replying.
<-- Like this?
06:51
cbg
Guys quick one when sending a command to ec2 machine I can see its working as when running a simple linux command like touch it creates
but when sending python run.py it returns success
which means the command ran but the script doesnt seem to be running
could it be that the code ran but then screen was closed and it stopped?
07:07
Are you sure that both python and run.py point to the programs you expect?
@MisterMiyagi You forgot to ask if their computer is on
"Have you tried turning the entire internet off and on again?"
I can try turning your SO account off and on again
I'm sure you can...
07:25
I realized the issue here it has been running well however due to the paths using its a case of using relational paths when requiring absolute paths
No one ever requires absolute paths
well when running the code it came back withpython3: can't open file '/var/snap/amazon-ssm-agent/4799/clone_repo.py': [Errno 2] No such file or directory within the errors the actual directory refered in script was os.path.join(os.getcwd(), 'clone_repo.py)
once changing it to an absolute path it worked
Um, /var/snap/amazon-ssm-agent/4799/clone_repo.py is an absolute path
yeah but in the script it wasnt refered as that
I see.
07:29
it was refered to as os.path.join(os.getcwd(), 'clone_repo.py)
Ah! Awful!
Your process cannot rely on the working directory being fixed
changing it to "/home/ubuntu/clone_repo.py" was what I have done is there a better solution?
@CodyGray I realize that now...
as to what I have done is there a better solution that having the path hardcoded?
Kinda depends on your overall architecture. I don't know enough details.
You could pass the absolute path to the file as an argument, which is what it sounds like you're doing. Or, you could add the containing folder to the system path, if you control the server.
08:04
@Kwsswart Can you clarify why you used os.getcwd() as the base of the path? Did intend to get the location of the script?
08:26
well i mistakenly assumed that the cwd would be where the first python script ran but turns out i misunderstood
You can use __file__ to get the path to the current module, or the .__file__ of a module to get that module's path.
For example, subprocess.__file__ gives you the path to subprocess.py.
This Q&A has a nice lineup: stackoverflow.com/questions/3430372/…
@MisterMiyagi thanks for that definitely will come in handy
08:49
Oh my, there's a lot of... bad advice in that Q&A...
Asked 11 years ago, 22 answers. Long tail of crap is inevitable.
09:14
Someone should clean that up. Shorten that tail of crap.
that's not so easy for non-mods when the crap has positive score
all of the cwd ones answer a different question
OK, let's do this.
and 3 more whenever they end up having negative score
pretty much anything without __file__ is wrong
yes, that's just a terrible and redundant answer
crap answers redundant answers that come 11 years late get the axe
uh oh, mods are deleting technical content they aren't an expert in :P
I'm an expert in crap.
6
I deal with a lot of it.
this one is an admission from OP too
> Solution works perfectly (and every time) when the Python file program (or CLI) is executed from the same directory where you are located and want to get the exact absolute path.
09:27
To be completely honest, though, I am a bit uncomfortable with the deletion (by anyone, not just mods) of answers like this. Even if wrong, they can be valuable because they contain a common mistake/misunderstanding.
Note that it is at least coherent. Therefore, not crap. Although it might be wrong.
Wrong and crap are orthogonal.
What value does a positively scored wrong answer hold? Honest question.
@CodyGray yes, but both can be grounds for deletion
Wrong answer is really grounds for downvoting, not deletion...
surely not
Not deletion by mods. Deletion by community? Heck yes.
> os.path.dirname returns upper directory from current one. It lets us change to an upper level without passing any file argument and without knowing absolute path.
that... is not the question at all?
@AndrasDeak It's unfortunate that it's positively scored, but that's y'all's fault (collectively, the Python community). The value it holds, independent of score, is that people looking for answers can see it, recognize it, then see the comments and understand why it's wrong.
"understand why it's wrong", yeah right
09:30
Hey! I'm an optimist!
In all seriousness, things like that have helped me in technology where I'm a complete novice and may have some misconceptions.
@AndrasDeak I... what? Why are you giving me that?
it's collected 7 upvotes since I've edited "don't use this answer because it is completely and utterly useless" into it
so much for voters "understanding why it's wrong"
I see.
I will confess that I did not understand that answer at all when I read it. Including your edits.
f'{foo=}' just looks like gibberish.
it will always print whatever you put in the string literal
09:33
So I assumed it was magically correct.
it is non-magically wrong
The question is wrong in the first place. There's no correct answer other than "you silly".
Yeah, that's a pretty common question in all languages, for reasons unknown. There is never a reason to do that.
The only possible reason is because you want to do something like eval. And then, well, duh, of course you're doing the wrong thing.
Then again, I guess all of Python is eval....
There are languages where it might make sense, and the language even has extrospection that does that. In python it's nonsense.
MATLAB doesn't have a concept of references, so pretty much everything has a name (though you still have temporary unnamed objects like arr(2:5).
In python you might be asking "what is the variable name of lst[2]?". Nothing, there is no name, and your question is not even wrong.
MATLAB still has matrices, though. Individual elements in a matrix cannot have names, can they?
Yeah, that's arr(2:5).
09:37
@AndrasDeak That... what? Why would I ever want that?
@CodyGray you really shouldn't, but you still can. There's also evalin('caller', 'thing_to_eval_in_callers_namespace_dont_ask_me_why');
auto GetThing(auto thing) { return thing; }
I found these creepy even when I was using MATLAB.
@CodyGray why did you spare stackoverflow.com/a/54007018/5067311 of all answers?
There's a lot of things I find utterly broken in MATLAB, but, wow. I can't even imagine a case where you might find yourself wanting to use this.
@AndrasDeak Because I got bored.
ah
thanks
09:41
@AndrasDeak Wat.
Why does this have almost 200 upvotes? oO
if you want even watter, look at the timeline with votes shown
and look at people giving passionate arguments in comments why it's not utter bullyam
It's answers like these that make living a live of a luddite hermit seem attractive.
well, you just have to accept that SO has become a dump long ago and sail across the Western Sea
there's still nothing wrong with flashlights and zippo lighters
Nothing wrong yet.
Lotta modz deleting commentz there.
Some kinda rude. Others not, just pointing out how totally wrong the answer is and recommending deletion.
I feel like joining the club of comment-deleting modz!!
09:47
I think I left a kind comment how it's crap which was hastily deleted. That's why I had to edit the answer itself.
> The number of upvotes on this answer make me sad.
I am not sure if that's "kind".
I mean, I've seen worse... :-)
If you had seen the alternatives I rejected, you'd know it is.
Heck, I've written worse. Probably today.
Of course there's a chance that heat detector picked up the comment and it was deemed unconstructive. In any case we're better off with my edit, even though it hardly changes the rate at which that pile of work gathers upvotes.
Perhaps the situation is that people looking for answers to that questions are confused to begin with, so they are inequipped (more so than usual) to tell that an answer is useless.
The "it solved my problem"/"works on my machine"/"why can't you just be helpful?" brigade.
09:50
Hmm, negative-rep bounties
Been there, done that. I remember.
Feature-requested, I mean. Not implemented.
I want to say it's been proposed more than once
I bet rene closes them all.
All the complex, "that's not possible" answers and then there is this one - literally one line without importing a single thing. Thank you for sharing this, good sir! — Artur Nov 5 '20 at 16:59
I love this.
I cannot tell you how many times a day I see this kind of thing
09:55
stick it to the man
I shared that, because you wouldn't be able to see it any other way.
(I loved it so much, I set it free.)
yup, I'm pretty sure I saw that before it was culled
I just deleted it. So, yes, likely. :-)
On the upside, my trust in our code base and maintainers has just skyrocketed.
09:57
Are you sure none of them upvoted this answer?
Because you just did a Ctrl+F without finding this?
Oh, and the answerer's comment is also 100% bullyam, just like the answer. The question was asking the same thing in its initial revision.
Hmm... I guess there's a mod election going on >:)
@AndrasDeak You're right. Better let loose the Spanish inquisition just to be on the safe side.
unfortunately "elect me so I can delete all the crap" didn't work out for deceze the first time he ran
@AndrasDeak Or Dharman.
10:00
Sounds like a convincing slogan to me.
@CodyGray OK, but deceze made it charming. Dharman is... with a different attitude.
I don't actually remember what deceze's nomination statement was
That was quite a long time ago
My takeaway was that he thinks there's enough knowledge and there's too much crap, and he'd like to help with the latter. It was nice, I think I voted for him.
Whatever it was, it worked for me the second time.
> For anyone who has ever wondered: "deceze" stands for my initials, D. C. Z.; it's not a misspelling of "decease". You can call me David. You may have seen me around, I've been here a while. I've been here so long that a lot of the time I answer questions by closing them as duplicates of answers I've written before, or of answers I've seen a million times already.
I love seeing and contributing new content, but quite honestly a lot of things here just need categorising, sorting and moderation by now, since the existing library of content is already so well established.
(linebreak mine to fit in chat)
10:03
Isn't it amazing that adding linebreaks to chat messages causes them to take up less space?
That year we got Madara instead of deceze, but that turned out quite nice.
Incidentally, he still keeps true to this. He closes zillions more questions (on average) than any other mod.
@CodyGray painters keep talking about "negative space"...
@CodyGray yeah, I often see him on the front page when I have time to don my hazmat suit and pitchtorch
 
1 hour later…
11:17
Sep 17 at 13:32, by MisterMiyagi
Admittedly, things generally don't break if you mess up Iterator.__iter__
Thanks a lot past me for that smug statement! *opens pull request*
Did you mess up Iterator.__iter__?
Technically it was __aiter__... but yes.
Did things break?
Violently.
11:33
bummer
Indeed.
 
1 hour later…
12:37
morning cabbages, folks
Python
Lend me your power
Not for any particular reason, I just want to be powerful
import antigravity
[gravity turns off within Kevin's room, but everything stays where it is because of inertia]
Or would everything resting on the carpet immediately spring up with exactly 1g of force... Hmm
12:48
As long as the earth still keeps spinning, things should gently float upwards.
Gently as in violently, I mean.
I have many questions, remind me to nerd snipe myself with them later
13:06
@Kevin we're spinning at 1k mile per hour, and sans gravity your room follows a tangent line
(OK, equator is 1k mph)
I'm like halfway between equator and pole, so I guess I'm going 500 mph. Still pretty good.
Factor of cosine latitude
Assume a frictionless conical earth in a vacuum
Ok, 1000 * sqrt(2)/2 =~ 707 mph. Even better.
Or worse, depending on whether I want to be tangented into space. If Python continues to lend me its power, I'll probably survive, with a fun story to tell. So I'll go with "want"
13:29
To be fair orbital speed would still take you at the poles
13:46
How can I trigger an overflow exception? I entered 999999999999999999999**999999999999999999999999 and now I just hear my fan being a bit louder
999999999999999999999**999999999999999999999999**999999999999999999999**999999999999999999999999 ?
Does it ever stop? Or is it gonna run out of memory? It's been going for a good 10min
I've hit memory errors in the past, writing my own neural network. It hit the MemoryError when computing the gradient (which was an exponent of a float). infinite loop appending to a list seems like it might also work
Ints don't overflow.
You can overflow on some builtin int-like operations, e.g. len bigger than sys.max_size.
@MisterMiyagi Right, I read that 10s before entering my example...
So it's gonna OOM?
13:53
flloat can also overflow on some weird corner cases.
I'm surprised it's trying so long
They probably felt it wasn't worth slowing everyone down just for the sake of the few people who point a loaded gun at their memory.
Hmmm it took google 0.56s to tell me the result is undefined :D
Any idea how to estimate how long this is gonna run for? I'm tempted to leave it running :P
Hey guys, how can I split these lists from string?
'[* TO 0.99][1 TO 1.49][1.5 TO 1.99][2 TO 2.49][2.5 TO 2.99][3 TO 3.49][3.5 TO 3.99][4 TO *]'
@MisterMiyagi do you have a simple example?
13:58
@Hakaishin You can estimate the number of digits and extrapolate from timings of smaller cases.
My first approach would be to hunt down whoever is emitting that output, and convince them to use something more standard, like json. My second approach would use re.findall.
@Kevin +1, strongly favoring the first option
@Hakaishin float(10**400)
neat thanks :)
Hmm, it's a bit aggravating to match floats... Are negative numbers possible? e.g. [-10 TO -1.23]?
14:07
no, but I did it just by splitting by "]["
Yeah that's probably easier honestly
import re
s = '[* TO 0.99][1 TO 1.49][1.5 TO 1.99][2 TO 2.49][2.5 TO 2.99][3 TO 3.49][3.5 TO 3.99][4 TO *]'
pattern = re.compile(r"""
\[              #literal left square bracket
(               #capture only the interior of the bracket pair, not the brackets themselves
    [^\]]       #any character other than right square bracket
    *           #any number times including zero
)               #end of capture group
\]              #literal right square bracket
""", re.VERBOSE)
seq = re.findall(pattern, s)
Considering how long it took me to compose this
Most of it was spent hunting down a particular behavior I didn't expect... On a completely unrelated note, guess the output of this code:
import re
s = "fooQbar"
pattern = re.compile(r"""
[       #character set
^Q      #anything other than the letter Q
]       #end of character set
+
""", re.VERBOSE)
seq = re.findall(pattern, s)
print(seq)
14:39
@Kevin huh
then again I never use VERBOSE
I use it if I'm giving code to somebody that I think will say "thanks! Now can you explain it in great detail?". May as well save myself a step.
but I can't say I understand why it behaves the way it does (i.e. as '.+[Q\n]')
but that's probably not even correct
oh well
If I understand it correctly myself, it assumes "#character set" is part of the character set. Then, since "^" is no longer the first character in the set, it's interpreted as a literal caret rather than a complement flag
ah, so it's just that 'b' is missing from your comments
So it matches "o", because it's in "other", and Q, because it comes after literal caret, and "a" & "r", from "character"
14:43
that makes more sense than the model I've been trying to form around this
right, 'f' is missing too
14:54
Is this answer a real answer, or an inside joke?
hey
It's an inside joke :)
>>> from __future__ import braces
  File "<stdin>", line 1
SyntaxError: not a chance
Hrm... trying to clean up the answers (super old question)
On that question, it's a real answer
Hoo boy, why are there so many mods around lately? Did something happen? Should I be worried? O.o
That's what I needed to know. Appreciate the help :)
14:57
No worries. And to be fair I wouldn't shed a tear if the whole Q&A were nuked...
I'm sure it has historical significance of someone complaining about the very syntax of python...
@Aran-Fey I let Martjin and Jean handle most of the Python stuff. Not much escapes their indented gaze...
@Aran-Fey smell of fresh meat brings them out into the sun ;)
Hmm, I'm a bit disappointed that none of the answers to that question explain why the Python grammar is ambiguous without indentation.
Does it help if I play dead?
#if indents are stripped, then this code:
if a:
    b()
    c()
#becomes indistinguishable from this code:
if a:
    b()
c()
15:01
@Kevin that wouldn't answer the question :P
the answer to the question is "no, it's not possible, and any IDE worth its salt will autoindent for you"
I don't want to answer the question. I want the question to push a boulder uphill for all time.
to fill a bathtub without a bottom
@Aran-Fey hmm, you are suspiciously using multiple accounts
Ha, that other account has already been playing dead for months though :P
cbg guys
15:13
my night shift job made me miss the room meet, but I can see some members got to meet others :D
 
1 hour later…
16:21
cbg everyone
Is anyone aware of an argument against having a built-in groupby that groups but non-sequentially?
sounds like the entire SQL community, if I understand your question correctly
I meant in Python, I see a lots of questions in SO related to non-sequential grouping that I think it could be added
Sounds like an itertools thing, but itertools doesn't like to consume iterables whole
I think the main problem there is figuring out which module such a function should be implemented in. You can't put it in itertools because it doesn't return an iterator. So where would it go?
ahh... I think pandas does that. itertools.groupby's sequential behavior is a frequent gotcha and definitely gotch'd me when I first started. I simply accepted it for how it was. I suppose the argument can me made for memory usage and itertools ties very hard to to be O(1) memory where possible. That's also why I'd just sort the list before a groupby
I suppose it could go in collections, but it would be a bit of a semantic stretch
16:30
Thanks for answering, I kind of agree with both of you is true that it doesn't have a module to put it. And I guess we could have a Grouper collection in addition to Counter
17:30
anyone know how I can tell flake8 to look ONLY at .py files?
17:51
The closer my lecture is tomorrow, the more I'm just copy pasting stuff together from the webs. Making a new course takes so much time :o
deadlines can be inspiring
@Hakaishin what are you teaching?
Python Intermediate. Before we had only a basic and advanced course... After a few years it was realized something is missing xD
A little bit of everything, project setup, virtualenv, dbs, web, http, apis, logging, exceptions, debugging, some tidbits of python that somebody felt had to be mentioned like arg, kwargs and random stuff I find useful/interesting or important that people know
interesting. If you had said "intro to programming/python", I would have pointed you to my slides from when I taught that. But they may not be relevant to your course. If you'd still like them, I can send you access to the gDrive folder
yeah, I definitely didn't cover any of that in my course
17:56
quite a practical course, which is nice. Feels a bit like a craftsman workshop less a theoretical lecture
Oh actually that would be really cool, I would love to improve my basics course, although I think it's already the best of the 3. The advanced is my bane and I will be muling over that in a few weeks. The thing is in the advanced the paths of what you can teach split so crazy, nlp is totally different than vision than reinforcement even though it's all machin learning. Don't get me started on all the different advanced topics there are in python itself like generators, meta classes and whatnot
I would actually love to take that course. Might I also add namedtuple and NamedTupleCursor to that list?
xD
Would be interesting to hear what people here thing are advanced features of the python language
From my experience, that depends 100% on the target audience. :P
I want to agree with that. I think a good approach would be to make it a seminar course: here are a few IDEs and frameworks and things like metaclasses that are advanced python. Now go prep a presentation on something sufficiently advanced (run it past me in office hours) that really like and present it to the class
BTW your topic selection sounds nice!
18:05
@inspectorG4dget That's actually a really nice idea, outsource the work of preparing a course to the students xD
for the intermediate one?
sounds like the audience is "web stuff"
@AndrasDeak xD It's the most graspable I feel like. The majority of people is from the humanities or some less technical research fields like geography/biology/law
Why do those poor people listen to advanced python?
But the advanced one is more into Data analysis like numpy, pandas and visualizations
it's not just that. It also addresses the breadth problem you mentioned - you'd have to trim down the content and you'd likely stick with what you know. This way, you get to scratch some blind spots as well. Depending on class size, you might even be able to add your own "relevant reading" list on top of your students' presentations
18:07
@Hakaishin ah
oh gosh! if this is for technical folk who don't necessarily start to salivate at the sight of python, I can't recommend Streamlit enough as a tool to "just get something off the ground right now"
@AndrasDeak because they get baited by buzzwords :D But yeah I often wonder why phds are sitting in the advanced course. I feel like if you are managing do get into a phd and stay there for longer than a year, you should be able to learn everything I present at about similar speed on your own. Nothing beats just reading the docs and SO. Come to think of it, maybe the socializing in the course is a substantial factor why people do these courses
I disagree, docs are inadequate to teach coding to newbies. Unless you mean the official tutorial.
@inspectorG4dget hmm, looks great, but looks like it hides too much details from the user
And if the student is sort of interested in programming but their work doesn't depend on it then taking a course can make sense.
18:13
@AndrasDeak Nono, I mean the advanced one. Basic/Intermediate make complete sense to have
@Hakaishin Wait, those are non-CS folks? My sympathies.
@Hakaishin don't know
I've programmed for so long in so many languages that I can't really put myself in a newbie's shoes.
Yeah it's from every possible direction. I had a 60 year old lady who never programmed asking me that she wants to program in colors. It took me until the 3rd course day of talking in the breaks until I understood what she meant :D
especially in the age of crappy youtube "tutorials" *shakes cane at whippersnappers*
@AndrasDeak Hahaha, I just had that experience in a pub yesterday. It was a bit loud and I thought I wasn't understood acoustically when explaining something from work. I was like: "Yeah I teach Python on Sat. ???? Confused looks. Repeat louder: PYTHON. ????. Realizes problem. Teaching programming :D
18:16
yeah, no, I wouldn't do that
I'm aware that many people can't find the typy end of a keyboard. I just don't know what "works" for someone who's learning programming.
I've been teaching for a decade and you have to recognise your assumptions about the knowledge of people you're talking to.
I'd say I'm good at it, but only face to face. Online I'd say I'm worse than average at it. It's really two different skillsets. Because bodylanguage and facial expression can show you so much what step was not understood. It's like having a live debugging session running
@AndrasDeak Lectures with hundreds of people or smaller practical stuff?
latter
Oh cool, what topic? physics or programming?
Physics and some math. Programming is mostly a hobby (well, and necessary for research, but that also means a hobby here :P)
Ah Academia <3
18:21
especially here
 
1 hour later…
19:50
Is it possible to print the area given by plt.fill_between()?
Unlikely.
Meaning what exactly? Just pass the return value into print, or is that not what you want?
I mean, it's possible, but not using matplotlib
@Aran-Fey plt is pyplot, and fill_between() is a plotting function
it gives you a nice coloured patch
And it returns a PolyCollection, according to the docs
Yes, and DarkRunner wants to know the surface area of the patch, i.e. the integral under the curve. I bet.
19:58
That interpretation of the question certainly makes a lot more sense than mine
I'm also factoring in some previous history and question quality here
That should be as simple as sum(poly_collection.get_sizes()) then?
there seems to be a get_sizes() method on polycollections, but the scare quotes around 'area' in the docs are scary enough
especially since polycollections have some scaling mechanics
@AndrasDeak Online chatrooms make you really appreciate the vast parsing skills humans have
I kind of have a PhD in extrapolating beyond healthy reason.
 
2 hours later…
22:09
@Hakaishin They thought you taught snake-wrangling?
23:05
s/struc\.\([xyzw]\).\+ = \(.\+\)$/\1.append(\2)/
<3 vim

« first day (4017 days earlier)      last day (1155 days later) »