« first day (2462 days earlier)      last day (2486 days later) » 

DSM
12:45 AM
@idjaw: I'm tempted to post a one-line answer to the question as asked, which would be "issubclass is just another function -- patch it too", but the freezegun approach is probably better..
 
1:01 AM
@DSM You could probably put that in there if they were looking to keep using the existing package they are using. At first I thought they were unittesting and that package was part of the code being tested.
Doesn't hurt to put it up there as an alternative
 
1:30 AM
@enderland Was just curious... last year a guy with a pathetic nomination, no actual moderation that they could do as a user, managed to gain a lot of votes...
 
@JonClements I guess I'd have the advantage that most people would recognize me, albeit from clicking HNQ on The Workplace :P
 
hey... who doesn't want a happy smiling face? :p
 
I think I'd do a good job if I was a mod, but there are likely better people who will run
 
I imagine most of last time will run (just a wild guess though)
 
yeah that's what I'm assuming and many of them would be better than I expect I'd be
 
1:40 AM
okay... if that's what you think :)
 
3 hours ago, by enderland
@JonClements you think I should run? I'm not sure if you are being serious or trolling me :P
:P
haha
 
definitely wasn't trolling
 
2:15 AM
maybe I'll think about it
also weird that there are me and two mods here... conspiracy :o
 
trustno1?
The truth is out there?
whistles the x-files tune...
 
 
3 hours later…
5:25 AM
:(
visited 1835 days, 1 consecutive
now how's that possible :/
I blame my vacation :(
 
5:44 AM
I generate a column with cumsum() of groups. I want to take last line of each group (basically it gives me the line with final cumsum of each group). I did ` agnost_last = ag_no_st.groupby(['team','InstrumentType','Symbol','ExpiryDate','StrikePrice','O‌​ptionType'])['qty'].cumsum().last()`
it gives me TypeError: last() takes exactly 2 arguments (1 given)
Initially I added a column like this ag_no_st['position'] = ag_no_st.groupby(['team','InstrumentType','Symbol','ExpiryDate','StrikePrice','O‌​ptionType'])['qty'].cumsum()
which works fine
But I want to last line of each group
because it contains the final position of that group
 
6:28 AM
@AnttiHaapala I think there should be a "grace consecutive" day(s) that should be given out.
 
Late night cabbage!
@JonClements lately I have been trying to do the whistle from "The Good, the Bad, and the Ugly" and it ends up turning into X Files instead....
@AnttiHaapala never take another vacation ever again. Can't afford to lose that consecutive days streak on SO.
 
user8167727
7:02 AM
What will be my parent profile when I ask stackoverflow to merge user profiles?
 
@mini I suggest explicitly stating which profile you want everything to go under.
@Kevin That is awesome! I will have to quote that from now one whenever I request a MCVE.
 
user8167727
I want to merge accounts ; will both of there reputation will be summed?
 
I don't know what the SO policy is about that.
 
That questions belongs on Meta Stack Overflow (might already be there), this is the python room.
 
user8167727
Never going to visit this site.
 
7:09 AM
why not?
 
He / she probably had a bad experience there.
 
I guess Meta.SO can be more hostile to noobs than SO main.
 
Hey anyone familiar with opencv?
 
@mini: your reputation will be re-calculated based on your posts. So all your posts are put together on the same profile and the votes for those are re-counted.
 
jjj
7:25 AM
Is it just me, or are the votes a lil messed up here:stackoverflow.com/questions/14924721/… ?
 
@jjj messed up how?
 
jjj
Isnt the one with three upvotes much better than the accpted one?
 
The one with 3 upvotes is a relatively new answer (2016) compared to the accepted one (2013).
 
@jjj it is not nearly as old as the accepted one.
 
jjj
Oh, right. Sry didn't notice that.
 
7:46 AM
cbg_ning
 
8:10 AM
I use df3['team'] = df3['TradeSeller'].map(team.set_index('id')['team']) to get team by mapping to id. Sometimes TradeSeller can be NaN, in that case i want tradeBuyer to be used.
 
I'm baaaaack!
Ew. Gross. Apparently a bug pooped on my monitor when it was off, since I wasn't paying attention enough to kill it
 
@WayneWerner wb
 
thanks :D
I hate circuits that aren't protected from lighting strikes
on the plus side it was literally only my motherboard that died
well, and our cable modem and wifi router
and thermostat for the AC
but as far as my computer goes... just the MOBO
 
@WayneWerner your house was struct by lightning?!
Also, AFAIK, isn't the house supposed to be lightning proof, and not the devices?
Pretty sure a voltage that high will anyway melt any circuit no matter the proofing done to protect it.
 
8:27 AM
I don't know that our house was. At least I wasn't able to identify a spot that lightning actually hit
 
 
1 hour later…
9:54 AM
I wish "Lose the godyam dict/list/set comprehensions and use a godyam loop" was an acceptable answer
 
@Rawing it can be.
 
No no, the phrasing is important.
 
@Rawing sure, so use it in chat ;-)
 
df.apply(formula(x),axis=1) how do i send the row to the formula and then use it as row.column in side formula. I know df4.apply(lambda x: -x.TradeVolume if math.isnan(x.Trade) else x.Volume,axis=1) uses x as row item
but since my formula has multiple conditions , i cant use it as lambda
I used it like df4.apply(lambda x: formula(x),axis=1) is this a good way
 
 
2 hours later…
12:10 PM
I have a column with date like 21-JUL-2017 10:15:00 and so on. How do I group by 1 hourly buckets ... i tried df4.groupby(['gp1','gp2'],pd.Grouper(freq='60T'))['col3'].describe().astype(int‌​) how do I tell grouper that it has to group based on time in the column that has date time like 21-JUL-2017 10:15:00
 
12:58 PM
morning everyone
 
cbg
 
\o
 
a plethora of cbg
 
cbg
 
1:16 PM
cabbage for all
 
1:26 PM
cbg \o
 
\o/ all
 
cbg
 
1:50 PM
is there a way to take certain rows of a pandas df based on type of the index? Basically I have a df with a load of integer-indexed rows and then a couple of rows with string indexes, and I want to pull out a df with just the integer-indexed rows
 
>>> import pandas as pd
>>> df = pd.DataFrame({'a':[1,2,3,4]},index=[0,'cat','vanilla',3])
>>> df
         a
0        1
cat      2
vanilla  3
3        4
>>> df[list(map(lambda t:not isinstance(t,str),df.index))]
   a
0  1
3  4
dunno if there's a more idiomatic solution
 
beautiful, thanks!
 
list(map(lambda D:
 
@LangeHaare actually there's df.index.map
probably what you need
@Rawing right, should've been a listcomp, but I had pd.apply and other mapping methods in mind
 
I think the above solution works without the list() call?
 
2:03 PM
it doesn't, for me
but if you stick with that, use a listcomp instead
df[[not isinstance(t,str) for t in df.index]]
but I still don't think that's the best thing to do
 
in python2 map returns a list, so it makes no difference there
 
oh, python 2...
 
yeah...
not sure why so many people use it still
 
indeed my workplace is firmly in python2 land
 
bleh
 
jjj
2:05 PM
same here
 
took your advice on the list comp, thanks for the help
 
so whats going to happen in 2020 ?
 
jjj
well, probably they will have to learn to put () after print
 
>> df.select(lambda t:not isinstance(t,str),axis=0)
   a
0  1
3  4
@LangeHaare ^
I'm pretty sure that's the idiomatic version
and axis=0 is the default
 
nice, that looks good, thanks
right now we're split between python (2.7) and matlab - but they've recently announced we're ditching matlab and everyone has to move to python... I imagine there'll be a shift to python 3 probably some time after 2020
 
2:11 PM
Man, every Python job around me either wants Django/T.Flow/Pandas and or numpy... :\ Guess I should pick up one of them instead of just being a Python float.
 
@LangeHaare I'd think that migrating to python3 should be much cheaper than matlab :P
@MooingRawr *pandas
and be a python integer instead: then you can be as big as you'd like!
 
no I meant actual Panda!!!! /s :D
@AndrasDeak but I like being imprecise...
 
5 bugs (pun intended) says they'll keep using python 2 way past 2020 :P (sorry, I know that was terrible)
 
@AndrasDeak sounds like rational thinking - we'll have none of that contaminating our business decisions, thank you!
 
DSM
2:53 PM
Thursday morning cabbage.
 
cbg
 
cbg \o Hope you didn't get wet this time DSM.
 
DSM
I got caught in the rain yesterday, more's the pity, but today it was fine.
 
3:12 PM
why is it so difficult to import a module from a certain path...
 
I hate code that takes around a minute to run... just long enough to get distracted by something else
 
Does your compiler+code take 20 minutes to start up before you can run any test/anything
 
@LangeHaare all the more reason to run unittests <3
 
@WayneWerner I'm doing data analysis tho so it's more like as I go along I want to see X or Y and it takes a minute to get it
 
ah. Well. There is that.
I recommend a Rubik's cube
or something similar
 
3:19 PM
rb folks
 
ciao andy
 
whoa, I just discovered a super weird import behaviour
# my_module.py
import sys
sys.path.insert(0, '/path/to/a/different/my_module')
del sys.modules['my_module']
import my_module

# /path/to/a/different/my_module/my_module/__init__.py
pass

# script.py
import my_module
print(my_module)
# output: <module 'my_module' from '/path/to/a/different/my_module/my_module/__init__.py'>
It directly gives me /path/to/a/different/my_module/my_module/__init__.py instead of my_module.py!
 
3:41 PM
That is interesting
that's not actually import behavior though - that's naming behavior
Oooh, just a test though - you should define something to see if it actually gets picked up, or if it's just lying about the location
 
no, it actually works. This is the first solution I've found that actually works.
it's not like it overwrites the original my_module either. I can do sys.modules['original_my_module'] = sys.modules.pop('my_module') instead of del sys.modules['my_module'] and they're different modules
 
weird
 
so I've achieved my goal, but do I want to rely on this obscure mechanic? hmm...
 
why in the world are you trying to do what you're doing?
 
basically I have a python/lib folder that holds all my self-made modules. I want my_module to be in there so I can import it. But I'm using git, and I don't want to have the .git folder inside of the my_module folder
So I've decided to put my_module somewhere else and just have a fake my_module in python/lib.
I'd have used a symlink if I didn't need this to work on windows
 
3:53 PM
you can use junctions on Windows, FWIW
 
so basically it's the Z in my XYZ problem :D
 
I'd just install my modules in my venv, but maybe that's just me?
 
are those cross-platform? I need it to work on windows and linux
 
you can make junctions on Windows, and symlinks on Linux - they behave the same
I don't know if they behave the same with git
 
oh, but windows and linux share the same python/lib folder
 
3:55 PM
and then there's also just munging your PYTHONPATH
if you're using the linux subsystem for windows, you can make the junction and I'm pretty sure the subsystem respects it as a path. Fairly certain it will for a hard link
 
I don't use virtualenvs, but I guess now would be a good opportunity to look into that
 
but I think that conflicts with your git aims
 
@Rawing I'm familiar with XY but whats an XYZ problem?
 
It's when your Y becomes an X
 
a 2nd-level XY problem, so to speak.
Another problem with a symlink/hardlink/junction is that my backup program is going to back it up twice... I don't really like any of my options atm :/
 
4:02 PM
your backup program needs to be smarter ;)
 
I could configure an exception rule for each of my modules...
 
symlinks should be ignored by backup programs, or configured anyway
So... just to make sure I've got this straight...
You write some programs and you stick them in /path/to/python/lib. You want these things to be available to your other applications that you write. So you might have something like lib/something_cool and lib/another_thing, and you'll do something like...
import something_cool
import another_thing

print(something_cool.do_it(another_thing.is_also_cool))
And you don't want to have something_cool and another_thing in your git history for whatever this new mythical project is, right? Cause they're unrelated and that would be dumb.
 
yep.
and I can't have my .git folder in python/lib cause I have multiple projects in that directory, and they'd end up using the same .git folder. So I need to have my module in /somewhere-o/else-o/
 
Then yes, you want to package something_cool and another_thing - i.e. have a setup.py
if you're looking to the future, you want to package them up as wheels and stick them in a directory, e.g. python/wheelhouse and then you can use pip install --no-index --find-links python/wheelhouse something_cool another_thing
whether that's pip install --user to install it as your local user, or you use something like pipenv to manage your python envs...
(which is a lot healthier if you plan on letting other people use your code)
also as an added bonus, if you desire you could build your new package, and have pip download and build all the wheels for you and just give someone a zip/tar file with all the dependencies for your project and say, "here, extract this folder and then run pip install --no-index --find-links /path/to/extracted/files/ and you'll have my app installed!
 
def x():
  if(y):
    return z
  else:
    #other stuff

--

def(x):
  if(y):
    return z
  # other stuff
which is preferred
 
4:16 PM
If you're not familiar with a setup.py, here's the simplest thing I could get to work: github.com/waynew/simplest-python-package
 
@LangeHaare depending if your other stuff rely on y. IE if you only want other stuff to run when Y fails, the put it in an else. if you want other stuff to run no matter what put it as the latter
 
@LangeHaare I tend to prefer "explicit is better than implicit", i.e. if: ... else:
 
I'm afraid I don't really get it, but... I'm starting to understand. I think. Up until now I've always had exactly one version of my modules - there's no distinction between "module for development" and "module for use". If I understand correctly, you're suggesting I make this distinction?
 
@Rawing you use 3rd party deps, right?
 
generally yes
 
4:18 PM
@LangeHaare pretty much my exception is if it's an early return or something. So I might have something like this
def do_something():
    if should_abort(): return "Aborting!"
    # Otherwise, carry on
@Rawing basically you should treat your other things as 3rd party dependencies. Even if you're the one that wrote them.
 
when I skip elses in that context, I leave a comment saying #else
 
If they're not part of your main application
 
So basically the correct solution would be to get rid of my python/lib folder altogether
Sounds like good advice to me. Thanks.
 
Yes, probably. So you'd have something like projects/foo, projects/bar, projects/spam and each one of them you could package up, and if you have a dependency on foo and bar from spam then you'd actually specify that in spam's setup.py
 
@WayneWerner my thing is basically "if input is a string, return it, otherwise do something to it and return it"
 
4:22 PM
It might be some work restructuring everything to work that way, but you'll be so much happier than you will be doing horrible hacks with sys.path.
Down that path (hurr hurr) lies nothing but misery and sadness
 
jjj
^I kinda like the pun
 
...I only just got it xD
had me like "pun? what pun?"
 
jjj
:)
 
I almost used a different term but I couldn't help myself.
 
cbg, all
Thank heavens, people will now have to pay to learn python the hard way bit.ly/2sUI39a
 
jjj
4:30 PM
Anyway, this was/is a very informative conversation, just one question: when do you know that something deserves another dir in projects? I'm not very experienced, but the boundaries between "packages" sometimes seem a litlle blurry. @WayneWerner
 
that's potentially a bad thing though. If Zed earns money from that, he might write more books :/
 
I don't get the context for this pithy banter about LPTHW
 
He wrote some stupid things about PYthon3
 
HE wrote dated things that don't apply anymore. Some of the teaching can be a bit confusing and misleading at times.
 
"python 3 is not turing complete" snicker
 
4:35 PM
cbg
 
That was my favorite
like... literally wrong
 
cracks me up every time I think about it hahaha
 
He also prides himself on his teaching "style", which is generally unhealthy and condescending, but since targetted at noobs, they don't realize they are being talked down to
Other advice: "Don't use a debugger, use print statements"
What he means is "I didn't want to bother learning a debugger, so I get by using print statements, and if it's good enough for me, it's good enough for you, newbie"
And yes, the whole "Turing Incomplete" nonsense is just classic - the dilettante who expounds beyond his own knowledge, then blusters that those who dispute his position are conspired against him
 
I always wonder with people like that if they've actually written major software in Python. Either they are way better at using print statements than I am, or they don't have to debug applications that have a ton of state that's hard to replicate outside of that context.
 
^
I think it's mostly the latter. For instance, David Beazley mostly just uses print statements. He also teaches more, and the stuff that he hacks on are usually pretty focused.
That being said, he's also behind the curio project, I think it is.
I don't know if he's released any other big things
and I mean technically speaking a debugger is just print statements...
 
4:43 PM
David Beazley is awesome - author of PLY, and has done much work in coroutine/async world for years
 
it just happens to be interactive print statements that let you walk through the actual flow of execution.
I don't have anything against people who just use print statements: I use print/logging statements most of the time.
 
You may be thinking of pdb - graphical debuggers that have live watch windows and active display of local vars are very much more than just print statements
But they are often an investment in learning how to use the features
 
but debuggers are another tool in my toolbox, and sometimes it's helpful to be able to use them
graphical debuggers are just extremely fancy print statements ;)
well, more accurately they're more like 'print(value); choice = input('would you like to change value?')`, but print statements are close enough
 
DSM
I tend to be a print guy, I'll admit. It works for me well enough, and I've written some pretty big applications.
 
ah, you're the one who said print(type(obj), repr(obj)). I knew someone offered that trick
I actually used it to some success a few days back
so, thanks :)
 
DSM
4:47 PM
I'm not saying I never do the pdb loop, but to be perfectly honest if you need a debugger to make sense of your code, your code is too complicated.
 
Sometimes that's not your fault though, and debuggers are essential in that case
 
I definitely use PyCharm's visual debugger whenever I can.
I've never actually used just raw pdb.
 
Not to be completely off topic, but they're announcing plans for Go 2 at Gophercon right now. It'll be interesting to see how that shapes up.
 
Interesting
 
So Go will go to Go 2?
 
DSM
4:51 PM
Heh
 
s/Go to/goto
 
real programmers assign the object to be debugged to a global variable and then inspect it in an interactive python session.
 
Isn't that what a debugger is? The global variable being vars() and the interactive session being kicked off with pdb.set_trace() ?
 
David Beasley was also, I believe, the original author of Boost, enabling (among other things) Python and C++ to talk to each other relatively easily.
 
@holdenweb I think it was Swig- dabeaz.com/software.html :)
 
4:56 PM
Not da beaz! -- Nick Cage
 
If you are stuck in a Linux console, you can also use pudb for quasi-graphical debugging
 
5:11 PM
Who's got a dupe for positional argument follows keyword argument for this?
 
dupe? I'd just VTC as typo, honestly
 
Yeah, I'm not sure of the overall policy for questions where the exception tells you exactly what's wrong
Also I need about 2300 more rep before I can vtc :P
 
5:26 PM
grumpy consensus is "if it's crap, close as non-dupe and roomba will eat it"
recbg
 
DSM
@KevinMGranger: you just need to find a lot more parenthesis errors in old accepted answers. ;-)
 
@AndrasDeak is that a fork of numpy?
I've been trying to troll the Ansible and asyncio tags, they're more or less the only two I have an advantage on 🙄
 
DSM
I haven't used any of the API stuff much. Is it possible to bulk-download every Python answer to scan for problems?
 
if we had only answerers who had advantage, SO would be a much happier place :P
 
Advantage meaning "I know them well but apparently not many others do"
 
5:29 PM
@DSM I'm pretty sure the queen bee over in the bot/cleanup room does that
 
that's what I meant
 
Ah that makes sense
 
@WayneWerner It's not often I'm right, but in this particular case I'm wrong again. Thanks for the correction
 
At least it's in the right direction ;)
 
You just needed a little boost to get there.
 
5:39 PM
Ouch :(
rbrb
 
If you're in too much pain, I can offer you a swig of this medicine.
 
That ought to be a good curio
 
Ah well, off for my daily constitutional. Tonight, alcohol will be involved. Rhubarb, all
 
You all are so sly
 
Sly?
 
DSM
5:43 PM
@WayneWerner: :-P
 
5:59 PM
afternoon all!
 
Ah good, it was worrisome only having one Kevin in here
 
Haha, this again... I stopped by a few months ago
and kept getting summoned back in here thanks to mentions of others hah,
anyways quick question
similar to a password box I guess..
I have a string, I want to replace all text with '*'s
so, giving thisisafake, output would be ***********
 
string = "*" * len(string) ?
If you're reading input from the terminal and you want passwords to not be echoed, however, that's a separate issue
 
its not, just a formatting thing
sex appeal. you know
 
'*'s are so last century, you've got the whole Unicode set to choose from
 
6:11 PM
whats a good one?!
 
💩, for when the password is low-quality
 
wow, that went downhill fast
 
I've never had the chance to prettify console output
haha
how do you use unicode? \UBEEFCAKE ?
this is getting printed in Windows command prompt
 
Oh, then you are pretty much stuck with ASCII
As we learned yesterday (repeatedly) no colorizing or text effects in the Win console
 
What if it's run via powershell?
 
6:33 PM
looks like there is a color printing lib out there for win console
 
7:19 PM
Welcome, please read our room rules : sopython.com/chatroom namely don't link a newly posted question.
 
Thanks
Didn't aware of that i'll take time to read it
 
Looking busy David :D
 
8:49 PM
okay - as far as the cwd, thats a mess up while me trying to come up with a snippet. There is a large requirement to switch working directories, as you will not know (of-course i didn't say) as its irrelevant here. i question still remains on how to archieve and move into a new directory. Focus on the issue and not on the butt. Else just read and move on — OK999 4 mins ago
thanks, that is what I am going to do, with DV and CV
 
> not on the butt
 
Ready for a really hard question?
I have these values: 2. x-box horizontal position of box (integer)
3. y-box vertical position of box (integer)
4. width width of box (integer)
5. high height of box (integer)
6. onpix total # on pixels (integer)
7. x-bar mean x of on pixels in box (integer)
8. y-bar mean y of on pixels in box (integer)
9. x2bar mean x variance (integer)
10. y2bar mean y variance (integer)
11. xybar mean x y correlation (integer)
12. x2ybr mean of x * x * y (integer)
13. xy2br mean of x * y * y (integer)
and I want to construct the image
is this possible?
probably not
 
as in "yes/no"?
 
what do you mean by construct an image ?
 
8:55 PM
black and white images
 
Yes it's possible, you can construct arbitrary images in Python.
How is the 17 item list relevant?
 
@davidism how do you know?
 
DSM
Those values are either consistent with some image, or they're consistent with none. If they're consistent, you can find a solution. If they're not, you can't.
 
I know I can make images
but I don't think I have enought data
 
Why don't you? 17 seems like a lot of data.
 
8:56 PM
they could be consistent with any number of imgs.
 
and I'm trying to convert the data back into the images since my cnn takes images
 
DSM
You're satisfying constraints. There could (conceivably) be many images which satisfy them (oops, Kevin'd by Antti.)
 
not this data
I'll just search for a letter dataset with accual images
not just values
 
Are we not using the same meaning of image?
 
noah wants to construct an image that matches the features...
 
DSM
8:58 PM
This conversation doesn't seem to be going anywhere, so time for an end-of-day coffee. :-)
 
agreed
 
... but that might not be very useful...
 
Sounds like the answer is "try, and find out." What do you expect us to tell you that you can't do by trying?
 
I'm just going to find a dataset with accual images
because why spend all the time to convert back to images rather then finding an alternative
 
9:00 PM
@DSM rhubarb
 
I know a dataset with handwritten numbers...
 
I'm leaving too.
 
link>
link?
 
Ugh you folks and your timezones. What am I supposed to do for 3 more hours? Work?
 
9:10 PM
whatever you do - don't focus on the butt
 
rbrb all
 
9:39 PM
unless you're doing laser tattoo removal on someone's buttocks; in that case definitely focus on the butt
 
 
1 hour later…
11:04 PM
 

« first day (2462 days earlier)      last day (2486 days later) »