« first day (2524 days earlier)      last day (2425 days later) » 
04:00 - 16:0016:00 - 00:00

4:37 AM
Morning cbg
 
4:56 AM
cbg
cbg @thefourtheye
 
Cabbage @tilaprimera :D
 
5:26 AM
Morning cbg
 
is there an easy way to turn a value into a generator that yields that value and then raises StopIteration? Like so:
>>> value = 'abc'
>>> value = value_to_iterator(value)
>>> list(value)
['abc']
this doesn't work:
>>> value = (value for _ in '1')
>>> list(value)
[<generator object>]
this works, but it's ugly:
>>> value = (lambda val=value: (val for _ in '1'))()
>>> list(value)
['abc']
I guess the easiest solution is to define a real function instead of a lambda... def value_to_iterator(value): yield value
 
5:51 AM
value = ('abc' for _ in [1])
list(value)
['abc']
works for me
 
well, unfortunately I can't hard-code the value into the generator :D
and the generator has to replace the original value of the input variable
 
other_value = 'abc'
value = (other_value for _ in [1])
list(value)
 
...uh ... that's... I feel stupid for not thinking of that.
 
I'm about to feel a whole lot of stupid. I jacked myself on caffeine to stay up... but I lowered my cognitive abilities by 90%... Hope I can still get the job done
 
the brain didn't get enough caffeine and went to sleep, eh? :d
 
6:07 AM
Sometimes the brain gets enough caffeine and craps out on me anyway... just to piss me off.
 
that seems simpler
 
@IljaEverilä Good one!
Hmm, I might as well stick with my value_to_iterator function now... a bit more readable that way
 
7:13 AM
cbg
 
cbg
 
@piRSquared \o
 
7:30 AM
cbg
 
7:41 AM
@davidism great! if you have something that can be tested let me know and i'll give it a try in our application (since it uses quite a few of the more advanced sqlalchemy features)
 
8:03 AM
I have a df with date as index, am adding all column values and want to append a Total row.
I did `pd.DataFrame(d1[cols].sum()).T` this has an index 0 and I append it to df. But I need Total being wrtten in the index column having dates
 
8:18 AM
Hi
I have a few matplotlib plots where the legends overlapped the data.
I moved the legend up to be above the chart area like in the "Legend location" section here https://matplotlib.org/users/legend_guide.html

But now it overlaps with my chart title. How do I move the plot title to now be above the legend?
This seems to do the trick: ax.set_title('Title', y=1.2)
Then just playing with y
 
I wanted a lambda that would take an argument and ignore it. Instead it would return an item from another list named new. On a scale from 1 to 10, how hacky is the following solution.
lambda x, y=new.__iter__(): next(y)
0 being not hacky at all, that's brilliantly pythonic. 10 being that's ridiculous
 
I'd say it's somewhere in the middle... it's not overly difficult to understand, but you'll get some weird looks. It would be better as a real function with a proper name and possibly a short doc
and lambda x, y=iter(new): next(y) would be strictly less hacky :p
 
8:36 AM
Add *args?
@Rawing for your problem: value = iter([value])?
 
Oh my! That's elegant enough to not even need a comment!
I'm actually gonna use that instead of my function
 
@AndrasDeak what do you mean "add *args"?
and iter([value]) is great!
 
lambda x,*args,y=iter(new) so that it doesn't break if someone passes a second argument by mistake
might be overthinking it
also cbg
 
cbg (-: nice thought... In my context it won't matter. But you just taught me something that I'll keep in ram for when I need it.
 
Cabbage!
 
8:52 AM
I was trying to freshen up this question with a dimension that was lacking from all the answers.
1
A: Renaming columns in pandas

piRSquaredOne line or Pipeline solutions I'll focus on two things: OP clearly states I have the edited column names stored it in a list, but I don't know how to replace the column names. I do not want to solve the problem of how to replace '$' or strip the first character off of each column head...

Cbg
 
You don't even need the args: lambda x,*,y=iter(new)
well, it behaves differently I guess. It'll throw an error if it gets more than 1 argument, but nobody will accidentally overwrite your y
 
I am using that lambda to be applied to each column value. I won't be applying it, pandas will. And as such, pandas will likely not be passing anything but x
Still, I'll be incorporating that knowledge somehow
 
@Rawing that's nice, I don't think I've seen that
 
Comment on 4-year-old answer:
Could you provide a more detailed example? — Saibot 33 mins ago
@Saibot For what exactly? Maybe you should ask your own question? — poke 7 mins ago
Yeah, then it would be marked as duplicate in 10 seconds :D — Saibot 1 min ago
meeeh
 
Yeah, it's rare to have a use for that. Sometimes you can see it in functions that have a boatload of keyword arguments, to prevent people from accidentally shooting themselves in the foot by passing them as positional arguments in the wrong order
I would like to see a case where we can benefit implementing both generic and non generic versions. I am having trouble to understand why this is necessary (or is it necessary at all?) and how to use this pattern properly. — Saibot 2 mins ago
So basically he's asking why to do it, now how to do it?
 
9:05 AM
@poke what do you think the correct course of action ought to be? I think they kind of have a point. Asking isn't bad, demanding is. If they have enough rep, they should put a bounty on it. My opinion
 
@piRSquared that's a weird function to apply. Why not just create a series from new?
 
@AndrasDeak I answered that question with a clear intent to show how to perform the task inline (I'm not certain that phrasing is correct). I gave a few alternatives but one of them is to pass a callable to the columns argument via pandas.DataFrame.rename. This was what I thought was a good balance between readability and being inline/one-line/pipeline... w/e
 
I didn't read any questions, just your messages here :)
Gotta go commute, rhubarb
 
happy commuting
 
9:35 AM
Random thought: while I don't like most websites' suggestions about how to interact with them (e.g. Facebook), I do like SO's thing of reminding me to upvote questions as well as answers. I am bad at that.
 
Correction! That was a thought. I don't think it qualifies as random.
or maybe it does
I'm put off by other websites when their reminders are clearly commercially motivated. In this case, it's a reminder to show some love for those who spent the effort to solve your problem or someone else's problem. I'd have to agree with you.
 
9:57 AM
@piRSquared If they have the same question and it would be closed as a duplicate that means that the question would already solve their question. If their question is different enough that the question does not solve it, then closing it as a duplicate would be wrong.
 
Hi, I have list of tuples: [(12, 2), (14, 2), (4, 1)]
How can I merge first values of tuples into one tuple and seconds values into second tuple: [(2,2,1),(12,14,4)]
 
>>> l = [(12, 2), (14, 2), (4, 1)]
>>> list(zip(*l))
[(12, 14, 4), (2, 2, 1)]
>>> list(reversed(list(zip(*l))))
[(2, 2, 1), (12, 14, 4)]
 
Thanks, Could you explain what * do?
 
Splat
 
list(zip(*l))[::-1]
 
10:10 AM
@piRSquared better
 
apparently pickle.load can throw an AttributeError...? I'm tempted to use except Exception: now...
 
@piRSquared
I understand. Sorry for asking stupid questions :)
 
No! Please, I was looking for an excuse to use that. Forgive my sarcasm. It is actually difficult to search for * (-:
 
Surprisingly enough, it's actually not difficult to google at all. This is my first result for "python asterisk": stackoverflow.com/questions/400739/…
so you don't even have to know what it's called
 
10:29 AM
@piRSquared That’s what SymbolHound is for :)
 
Great link! Bookmarked!
 
10:43 AM
I have a question, when I run a command like conda install -c anaconda tensorflow-gpu, do I need my conda env activated?
 
11:26 AM
Am I misunderstanding this question or are people helping that OP write smelly code?
OP is like "I want to call these functions, and they should automagically use only the correct parameters, but I'm not going to define what "correct" means" and people are like "take my upvote + here's some code for you"
 
Smelly code, smelly code... why are they typing you?! Smelly code, smelly, it's all their fault!
@Rawing For what it's worth, the answer is by Coldspeed.
MSeifert's approach was what I expected, and is quite nice to know.
 
hi
everyone
i am facing this issue : for row in reader :
^
IndentationError: unexpected indent
Here is my line for **For loop ** : for row in reader :
kindly suggest
as i am new to Python
 
20
Q: I'm getting an IndentationError. How do I fix it?

Christian DeanI have a Python script: if True: if False: print('foo') print('bar') However, when I attempt to run my script, Python raises an IndentationError: File "script.py", line 4 print('bar') ^ IndentationError: unindent does not match any outer indentation level ...

 
any help is highly appeciatable
reader = csv.reader(csvfile)
for row in reader:
now this line for loop , saying syntax error
for row in reader:
^
SyntaxError: invalid syntax
like this
:(
 
11:49 AM
^ please read
 
Lol
 
@ShobhakarTiwari That line alone won't cause that error. You'll need to provide a MCVE.
 
Kevin's comment disappeared from the starboard again... that one's really handy, because it comes with a preview
unlike the sopython link
 
11:54 AM
i just want little bit hint about this , as i am trying from 1 hour for this
it would be great if you guyz put some comment on my question
 
5 mins ago, by vaultah
@ShobhakarTiwari That line alone won't cause that error. You'll need to provide a MCVE.
Even better: ask your question on the main site.
 
no issue , let me try first then will put question
thanks for response
 
recbg
 
work cbg
 
@AshishNitinPatil is that an excuse or reinforcement?
 
12:05 PM
excuse
 
I'm not sure that "coldspeed answered" makes OP's case better :P
 
I think coldspeed usually does post answers of the form "you're doing it wrong, do this instead"
 
@AndrasDeak I don't think it makes OP's case better. Just that the attention it is getting can't be helped. Plus, MSeifert's answer was the one I was interested in :)
 
@Rawing ugh. foo(lambda data: foo_1(data, 'arg1', 'arg2'), lambda data: foo_2(data, 'arg1'))?
 
IMO, the question in itself doesn't deserve downvotes as such, but certainly does warrant some warnings to the OP, as done by MSeifert.
 
12:17 PM
I fail to see those “warnings to the OP, as done by MSeifert”
I’m merely seeing an alternative suggestion without an objective explanation why that would be better or worse.
 
Well, some level of warning. Maybe not enough.
 
@poke I think the question is horribly unclear, so I have no clue if that would solve OP's problem. Perhaps he's loading the argument list from somewhere
 
> But a better way would be to simply associate parameters with functions that doesn't rely on introspection.
 
@Rawing a lot of those questions shouldn't be answered at all
 
@Rawing yep, still agree with your initial assessment. People are just throwing darts around.
 
12:18 PM
that's my main issue with their body of work
 
Can you give some background for what you are attempting to do? Right now, this only appears to attrack gimmick-y solutions that may solve your specific requirement but will otherwise not improve your code quality because the initial situation is already odd. I don’t see why creating a wrapper function here wouldn’t work for example (e.g. foo(data, foo_it(func_1, 'some_par'), foo_it(func_2, 5, 11))). Where do those values come from, what are you trying to do? — poke 12 secs ago
 
@poke *attract :)
 
whoops, thanks
Sometimes my mind is really weird.
 
needs more answerer shaming;)
 
“I’m voting to close this question as off-topic since it’s an XY question that, while being properly written and technically on-topic, will in its current form only yield solutions that should never be considered for productive purposes and only suggest terrible programming practices.”
 
12:41 PM
@poke I was hopeful to see 1 close vote. Any particular reason for divulging from this reason? :-p
 
@AshishNitinPatil Custom close reasons are posted as a comment :P And that comment seemed harsh? :P
Also, I’m actually waiting for OP to respond.
 
well the autocomment can be removed ;)
 
@poke well, in some way, it has to be a bit harsh :-p
But yeah, we could say terrible bad programming practices
toned down? :-p
 
Trying to run this but too many errors. I m currently stack here x_anomaly = np.fromiter(events['anomalies_dict'].iterkeys(), dtype=int, count=len(events['anomalies_dict'])). I found that iterkeys is deprecated and tried items()but no luck
 
Just spent 30 minutes trying to change something in an SVG without messing up the file completely (tried both Illustrator and Inkscape, both failed) just to end up editing the SVG by hand. What a mess, why isn’t there a real good tool for SVG?
 
@Sotos the code from that article is not compatible with Python 3. Anyway, items is not a replacement for Python 2's iterkeys.
 
@poke you mentioned the two tools I'd recommend
 
@vaultah any way to make it compatible with Python 3?
 
1:25 PM
They are both great vector graphics tools, but they seem both incapable of editing SVG without rewriting them completely (Illustrator here more because it cannot do SVG well in general; Inkscape sucks here because it does too much in SVG and won’t stay consistent)
 
Wouldn't it be keys()?
 
iteritems => items, iterkeys => keys, itervalues => values
 
@AshishNitinPatil Thanks for the link. I will dive in
 
They use izip(count(), y) instead of enumerate(y) :-/
 
1:28 PM
@Sotos But if it's just some basic stuff, poke's & Robert Grant's suggestion should be much simpler.
 
@vaultah thanks, I was about to post that.
 
Do star my messages temporarily though to make me edit them quickly so they look nicer.
 
:/
 
1:30 PM
@vaultah wasn't me :)
no problem
 
Of course ;)
 
@poke That was it. Works now
 
\o cbg
 
@MooingRawr o/
 
Oh there isn't a life advice SE site, interesting.
 
1:36 PM
parenting though
which is like life advice for people with children.
And work life thingy, for people with jobs
and SO for people with programming problems, which is the majority of some people’s life.
 
Hi. I know I'm stupid but how will job employers contact me? I clicked on "Ask a question" and sent my question to them.
 
huuh?
 
Was hoping for a just general life advice like friendship advice or stuff like that
@S.Ahmed are you talking about StackOverflow's Jobs ?
 
@MooingRawr yep
 
What does that have to do with Python?
I'm sure those people will do whatever they want to.
 
1:41 PM
@S.Ahmed You seem lost. sopython.com/chatroom
 
@S.Ahmed I would recommend that when they contact you, not opening with that.
 
@S.Ahmed And, if you use that phrase quite often, you should rephrase it.
Something like "This might not be a good question, but..."
 
Or "I know I'm still stupid, but..."
Just to acknowledge the lack of progress
 
@RobertGrant that might be considered rude, but it was hillarious XD
 
1:44 PM
otherwise Quora
 
Or Reddit?
 
Oh interesting. did not know this existed.... but yeah was just curious about it :\
 
@RobertGrant -_- XD
 
Short of the standard, going to a bar and asking the bar keeper, was hoping a newer solution would appear lol
 
These are quite interesting questions - on the Inerpersonal Skills QnA
 
1:52 PM
74
Q: How do I deal with other people's screaming children in restaurants?

BeofettI want to start off by saying that I'm not referring to "family friendly" restaurants or other venues where a loud, informal atmosphere might be expected. I'm specifically asking about dining establishments where, under normal circumstances, a conversation is typically quiet, and there's general...

 
Thanks, that might apply to flights as well.
 
@AshishNitinPatil very very very true
 
But alas, I would not like a seating outside the aircraft :|
Too cool to be outside.
 
cbg
 
Wondering if I could reply to that answer with this
> Sadly, this solution is somewhat invalid for a flight :|
It's not reddit after all
 
1:56 PM
@AshishNitinPatil :)
Sadly it's been downvoted, and more sadly people are seriously discussing my question
Although I must commend their attempt to try and clarify things; I feel a bit bad that they're such nice people
 
@AndyK My brain just skipped a few words and I read “How do I steal other people’s screaming children” – probably from kidnapping.SE
3
 
@RobertGrant sorry, not following the context
link?
 
@poke well ... sometimes, you're secretly wishing to steal them to sell them to some rock band where they will use their screaming powers for everybody's enjoyment ...
 
Is that so?
 
2:08 PM
That is amazing
 
a cat picture? And no one got kicked?
what's the meaning of this
 
 
Ah, the other angle
 
hey guys, anyone here built web applications using Python? I've only used PHP for my backends in the past but I've got a project coming up and I'm thinking Python may be a good fit. The app is going to be crunching a descent amount of calculations. My dev time will be a bit faster with php because of experience but if its a no brainer to use Python for any computation then Id like to know. Curious to see your thoughts :)
 
I think it's safe to say the regulars in this room have written several web apps using Python
and in general Python is extremely common for web applications
 
2:21 PM
I could of probably skipped that part haha
 
@idjaw well, with davidism here, quite safe to say that (not as a direct implication) :)
 
My idea is to just make a Python service which handles requests, crunches the numbers and sends back the results. I'm guessing it'll be a bit faster than php
 
sure, you can do that. Faster? depends how you develop it.
Python has some solid math libraries. Which I never used
 
Python is not necessarily faster nor slower than <insert_other_programming_language>
 
^^
 
2:23 PM
It is cooler though.
3
 
definitely.
Nothing like having hissing sounds while the maths are calculated
 
and the syntax is a lot prettier than php
 
That’s subjective
 
I assumed Python would be quicker doing matrix operations than something such as php
subjective
fact lol
 
short, healthy commute, rbrb
 
2:27 PM
a seasoned veteran of a language can make any language look readable.
because you start realizing that shoving everything in to a single line and obfuscating is silly and deserving of tribal sacrifice
 
tribal sacrifice lol
 
is that a common practice among the lego people?
 
yes
we don't joke around when it comes to code design in Legoland
 
note to self: don't mess with idjaw
 
nods
 
2:31 PM
recbg
 
cbg
 
cbg Andras
 
DSM
Morning cabbage for all.
 
@Daruchini matrix operations with numpy are fast, yes
cbg, DSM
 
2:36 PM
@AndrasDeak thanks for the confirmation
 
morning @DSM
 
of course you need to use it right
but the idiomatic tools are usually written in C
 
have to use it right?! theres always a catch -.-
 
DSM
FWIW I set an intern this summer to making a calculation interface with Flask which received requests, did calculations, and then returned the results in various formats. He pulled it together quite well and had never used Python before.
100% test coverage, too. I was quite proud.
 
awesome!!!!
way to go intern
 
2:38 PM
Nice. I'm excited to get started but i'm holding off at the moment. My company have a tendency to make last minute changes which most of the time are whole spec changes
On another front, has anyone ever been to a chiropractor before?
 
I don't think dinosaurs are real, sorry.
 
They are
You muggle.
 
yeah. I went to see a chiropractor once and asked them why pretzels make me thirsty....
the doctor told me to leave....I couldn't figure out why
 
@idjaw why the leave part, or why the pretzels part?
 
Hi
I did google this, but I'm struggling a bit still

I have three 1-dimensional ndarrays that I want to put into a new Pandas dataframe as columns.

I think I should combine them into one ndarray (with three columns) first.


All three ndarrays have shape = (86400,)

I tried using vstack to combine them, but it is not working correctly. It seems like it is creating something like three rows, each of which containts an array...

Can someone please help?
 
2:43 PM
why do you think that?
 
@poke I was being silly in a silly way....but my joke did not go through as expected
we should move on
 
:(
 
df = pd.DataFrame({'a':array1, 'b':array2, 'c':array3})
just with better names
 
It's OK....I'll have another chance to make up for it soon
:)
 
@idjaw I quite enjoyed it
 
2:43 PM
Thanks Andras, I'll try that quickly
 
@idjaw That’s just like your doctor telling you to leave :(
 
@Daruchini on a more serious note I have a tendency to believe in science-based medicine
 
@poke I need to find a doctor that understands lego needs
 
@AndrasDeak As opposed to?
 
as opposed to smoke and mirrors and harmful charlatanism :P
 
2:44 PM
@AndrasDeak that worked. Thanks
 
DSM
Until two chiropractors can agree on a diagnosis it's hard to take them seriously. It'd be one thing if the results were unambiguously successful and it was just that their theories were quackery, but that's not the situation we're in.
 
I just want to get my back clicked. It's in agony
 
I don't know much about chiropractors, but the little I've seen ranged from "let me prod you with this plastic nub so that your legs are now equally long" to "let me just put my knee into your spine, see how better you feel now?"
 
Hell I'll let a fortune teller do it if they want
Sitting at a desk all day isn't good
 
there are a lot of people who don't sit at a desk all day long
They stand before it, walk before it, sit on balls, etc.
@Mierzen no worries
 
2:47 PM
I'm bound to a chair
 
sounds kinky
 
fitness-superstore.co.uk/…. Reasonable request?
 
I wouldn’t get one where everything is connected
Rather a large standing desk and just put a standard treadmill below
 
Modular
 
a previous place of employment had a treadmill desk in meeting rooms
 
2:50 PM
Nice. I quite like the desks you can toggle between sat down and stood up
 
If your workplace really cared about you, they would fill your office with neutrally buoyant saline solution
 
I don’t think that’s good for your muscles
 
but it's great for your back
 
There are muscles in your back too
 
*spine :|
 
2:53 PM
Well obviously they would also have to install an underwater centrifuge to simulate the effects of gravity during your workout
 
My requirement for a workplace is to not use fire driven development that leads to burnout and people who are not jerks
after that I'll be quite happy.
Free coffee too I suppose...but I'm willing to look past it as long as the first two requirements are met.
 
Yeah, I have free coffee. A wide variety
 
But if you don’t burn out the people, how will you prevent them from becoming jerks!?!?
 
Nerf guns and bagels
coddling and swag. Works for nerds all the time.
 
2:55 PM
But if you don't work people to the point that they quit in frustration, you'll have to eventually give them a pay raise instead of hiring more drones at entry level salaries. I just don't see how that's sustainable.
4
 
that's a fair point
 
Here at TheseusCorp we make sure that we swap out all of our component pieces every three years
 
Or dismissing their excellent work and not providing them with the fair bonus/boost in salary which eventually frustrates them and has them questioning life.
 
@Kevin it depends very much on the company strategy... some companies like to hire young bucks, grind them to tears and dump them, saying that they were too weak to take the pressure
 
> not a good fit
> refuses to kill self to make President Business happy
 
2:59 PM
@AndyK sounds familiar
 
@Kevin but in the long run, those kind of companies are bond to fault. But after my own observations, even if they fault, those who own the assets will be happy because they extracted all the possible values ...
@idjaw agreed with you, I want to live as a Man, not a slave. @MooingRawr capitalism, simply ¯_(ツ)_/¯
 
Honestly all I want in a work place is a decent wage, people who cares and aren't out step over others to get higher, helpful environment, with little to no stress. might be dreaming too much.
 
@MooingRawr we live in time, where we are disposable
 
shrug there isn't a time line where humans aren't disposable...
 
@MooingRawr there are solutions
 
3:05 PM
One of these days I'm going to move out into the woods and live happily for about eighteen months before I die of some disease that has been eradicated everywhere that has actual society
 
@Kevin lol
 
"Hmm in hindsight I shouldn't have put my poultice for broken bones on the highest shelf"
 
on a more joyful note, a friend of mine sent me this thenewatlantis.com/publications/shop-class-as-soulcraft
I do agree
 
I'm starting to get tired with the routine desk job of having to work to please superior and get notes on how you did this right, but not right enough to justify attaining your pursuit of X
 
@idjaw build something that can last for some time
 
3:11 PM
self-spreading viruses
 
rb folks
 
cbg
I feel like my time clock should have the capability to return "input error: needs more caffeine"
 
3:29 PM
Sometimes, I wish we had a “question too stupid” close vote…
 
mid life crisis... except I'm no where near mid life, and fifth life crisis doesn't sound correct.
 
cabbage all
 
waddup Wayne, how goes it
 
Well, I think
Huh. That's interesting and maybe accurate...
I just read a book to my daughter last night. Pythons are the longest snakes in the world, growing up to 30' (schoolbus) long
Anacondas don't get quite as long but they are heavier
so the Anaconda distro of Python it's everywhere, but it has a lot more bits in it :D
 
today has been a successful day
This morning I had a web application which loaded 24 javascript files on each load. Now I have 1
 
3:53 PM
Nice!
 
That’s easy:
<script src="file1.js"></script>
<!--
<script src="file2.js"></script>
<script src="file3.js"></script>
…
<script src="file24.js"></script>
-->
 
(sorry)
 
haha
if only
 
This made *my* day:
https://www.facebook.com/BUILDATORY/videos/693616934126075/
 
3:53 PM
(didn’t mean to devalue your effort)
 
It's ok. @WayneWerner filled the void
 
@toonarmycaptain now let's see it do it in the theoretical minimum of 21 moves!
 
right i'm off. Thanks to those who gave me advice earlier.. rbrb all o/
 
@WayneWerner That may take it longer to process, lol. Apparently it's down to 20 now.
 
04:00 - 16:0016:00 - 00:00

« first day (2524 days earlier)      last day (2425 days later) »