« first day (2665 days earlier)      last day (2276 days later) » 
00:00 - 18:0018:00 - 00:00

6:03 PM
Is there a reason downvoting takes away from your own Rep? Just got to a rep where I can do it and noticed.
 
Yep, as soon as Terry is finished, it gains self-awareness
I think it's to prevent people from doing it willy-nilly
 
Thats what I figured but was curious if there was a bigger reason. \
 
This is just my guess, I think I'm the lowest-repped regular in here. I don't know too much of the main site's culture and practices
 
Ive recently started coming here more after my account was blocked from a question limit. (still trying to work out of that) But I also have a low rep. I almost lost my ability to down vote by down voting like 4 posts/answers.
 
That means it's time to help the community back by giving some (quality) answers!
I know that's pretty hard to do for python-- most of the good quesitons have been answered already, and the high-rep python answerers are on the tag like a lazer. But there's value in providing a more in-depth answer to an already-answered question, or finding some edge cases no one's answered yet.
 
6:10 PM
Ive been amazed by how fast some high reps can get to answers in the python tag. I have gotten a few answers off on some low hanging fruit recently, which in turn did help. Ive moved towards watching other tags like pyqt4 and AHK to help too.
If only I could go back and tell young me not to post stupid questions on stack I wouldnt be in this boat.
 
You should look at my first questions. They are pretty terrible. However, funny thing is that those types of questions are often the ones lots of people have.
 
Oh yeah. One of my first ones did very well with a few upvotes and a good amount of views. Sadly non of the others caught as much positive attention.
 
Finding specific subsets help. I still need to answer some old, untouched asyncio questions I found.
 
I've answered 4284 questions and asked 224 of them. There is a wide distribution in quality.
You get better and quicker. It's like the farmers commercial
"We know a thing or two because we've seen a thing or two"
 
@KevinMGranger I think thats what Im starting to do now with AHK and such. Just trying to find a tag that has less people answering but a decent amount of users asking.
@piRSquared so true. I just need to ramp my rookie numbers up and get a higher number of quality answers out. Ill just have to be quick on my feet to try and get an answer out before the big dogs do.
 
6:18 PM
No, don't game it. I know it's gamification and all, but don't. Find tags you care about. If others answer there too, good! Learn from them and get better. Quicker answers are not always the best. Aim to add real value to the site and trust others will see it. If not, take solace in the fact that you answered well.
 
Yes all joking aside it is not a game. And I have been doing that and actually have learned a good amount.
 
Life is a game.
 
Definitions of "game" and metaphysics aside. My point is that finding low traffic tags is a "Short Game" tactic. Getting better at the things you care about and getting better at communicating is a "Long Game" tactic.
 
Oh for sure. I meant I am finding tags with less traffic that I still know something about, such as AHK. I just have yet to find any other tags that I am able to give good answers in.
 
If you like python, stick to python. Its difficult, but don't let that discourage you. Let that motivate you. Try to answer the questions. If you get beat by a mile, learn from the others, add useful comments. Ask useful questions. Do it a lot. You will benefit greatly.
 
6:32 PM
Noted! Thanks for the advice
 
6:52 PM
Welp I downloaded Eclipse and the JDK to see if it disallows unreachable statements and before the IDE opens I get java.lang.RuntimeException: Exception in org.eclipse.osgi.framework.internal.core.SystemBundleActivator.start() of bundle org.eclipse.osgi. so I guess this mystery will go unverified for a while longer
 
Or, that was the verification you needed.
 
If we have a canonical target for "why doesn't my code get faster when I run it with threading?", Python How to run a function n times concurrently, multiprocess fails could use it. Not necessarily for hammering, but useful to OP either way
 
7:11 PM
>           assert False  # I don't see how this could ever happen
E           AssertionError
*sighs*
On one hand I'm glad I put that assertion in, but on the other hand I feel stupid
 
lunch time cabbage
 
cbg o/
 
cbg rawing
 
I know this isn't python, but it still needs burninated
 
7:36 PM
Hi guys, can anyone help me with this small problem. How do I make x to print 1-42 instead of 1-41
I am doing a range which is taking out last but i want it to give me all #s
 
for x in range(int(hyphensplit[0]), 1 + int(hyphensplit[1])):
 
ahh ... I did int(hyphensplit[1] + 1 and it was failing
so I thought maybe adding + 1 is not possible
 
int(some_string + 1) doesn't work but int(some_string) + 1 does work
 
ok .. thanks!!!
 
wim
Aug 15 '16 at 13:46, by Ffisegydd
On the other hand, I feel like in 60 years time our descendants will be working in Type Camps, cursing us for not fighting against the Type Oppressors.
doing the lords work @DSM
Vive la résistance
 
7:50 PM
blizzard-airport-lounge-cbg
 
Do the type annotations on the data class atttributes even do anything? It's not like 3.7 validates the attributes' types, or does it?
 
no
nothing has ever validated anything. type hints.
 
Then I don't see the problem. IMO it's a nice, short, self-documenting syntax for declaring classes
 
slippery slope
today they want us to hint, tomorrow they are sending us to the Camp
 
pffft, you lot are such pessimists. No trust in Guido? :P
 
8:07 PM
A great deal of recent Python features motivates me to spend more time learning other languages
3
 
and why?
strange attitude indeed
 
meanwhile, I tried out a different language and promptly returned to python.
 
exactly
I am even going to try writing javascript in Python
 
@AnttiHaapala I'd like to be ready when "modern Python" no longer feels like Python
 
we can always go back to forever 2.7 ;)
 
8:21 PM
the libraries make it python
 
@AndrasDeak I'm not that conservative :P
 
@vaultah so what exactly are you complaining about?
type hinting?
 
cbg all
 
Python is like English...
@inspectorG4dget cbg
 
you get a cabbage!
 
8:22 PM
long time no see
 
EVERYBODY GETS A CABBAAAAGGEEEE!
indeed... been working my butt off
just finished building some CLI tools for progress monitoring, so I'm taking a break
how's you?
 
paying taxes is fun
 
ugh... it's terrible
 
when they're corporate taxes and you've made lots of profit
 
le sigh
 
8:27 PM
I'm hoping my taxes will go towards filling in the chunks torn out of the road by the snowplows that my taxes paid for
 
Funny you should mention that: I witnessed an accident yesterday - a truck flipped on it's side on a major road near my place
 
@Kevin Sounds like a good GDP contributor ;)
 
le s*ht
let's hope my plane isn't late
 
yeah. It must have been carrying a lot of cheese... debrie was everywhere
 
:D:D:D:D
 
8:29 PM
A fiscal policy enacted by our mayor, the woman who swallowed a cat to catch the bird to catch the spider to catch the fly (but who knows why)
 
Kev: who's your mayor?
 
@inspectorG4dget nice try :P
 
Outside of my one-man improv universe, I don't actually know
 
Who was it that said the American economic hero is a litigator with incurable cancer going through a costly divorce?
 
Socrates, I think
 
wim
8:57 PM
>>> from glob import glob
>>> glob('/root/*')
[]
just got bitten by this :(
glob fails at failing!
 
<3
bash:
$ ls /root/*
ls: cannot access '/root/*': Permission denied
zsh
% ls /root/*
zsh: no match
 
yes, non-matching glob behavior is broken IMO
there's an option for it in bash at least
 
can anyone think of a way to use _ as "the result of the previous computation" in a listcomp?
 
I thought _ is just a normal variable
 
it can be used that way, but it can also be used to capture the return value of the last expression
 
9:05 PM
Only in the REPL
 
Oh, yeah
 
wim
is there any fix for glob?
3rd-party is ok
I want an exception there
@inspectorG4dget please clarify behaviour ... you want to refer to the previous value in the list comp?
what should happen for the first element?
 
yes. Trying to write a one-liner fibonacci
 
wim
you need 2 prev values then, don't you?
 
Could always be a tuple
 
9:10 PM
I wonder if there's a way to "use previous and current, to compute next"
 
wim
you can do it with numpy
 
... or tuple. Robert's go the idea
well, my current solution is to hack globals(), but I feel like that's a copout
@wim how so?
 
wim
it's kind of a cheap linear algebra trick
 
hit meh
 
wim
but np.array([[1, 1], [1, 0]]) will generate fib numbers when multiplied with itself
 
9:12 PM
rofl!
 
wim
hehe.
 
is there a way to refer to the list being created within the listcomp that creates it?
 
wim
no, it doesn't exist yet
 
how about if I made an ast?
 
wim
why you want to do it with a list comp, this is exactly what generators are for.
 
9:17 PM
@wim that's neat, so you can generate the nth power from the spectral decomposition
 
fine, a generator then. How would I make a generator make fib numbers?
 
well, keep track of the prev and current and yield in an infinite while?
 
in a one-liner?
 
your scope decayed :P
 
9:19 PM
@wim not a oneliner
 
wim
you appear to be suffering from onelineritis
 
heh. I'm working on a challenge (which technically I've already solved with the above mentioned globals() hack) - not on prod code
 
wim
remember, two lines is just one line with a newline character in the middle
 
death is just life after a line
 
wim
@AndrasDeak I'm not sure what a spectral decomposition is. it's just obvious when you multiply out the rows and columns.
 
9:23 PM
@wim it's when James Bond movies are forgotten
 
It might be more familiar as a singular value decomposition. When you decompose your matrix as lambda_1*|1><1| + lambda_2*|2><2|. That's how you can compute matrix functions (including large powers) for normal matrices
 
wim
ah, yeah I know SVD
wow that takes me back to my computer vision days
> the interpreter creates a secret name that only exists while the list is being built. That name is (usually) "_[1]", and it refers to the bound method "append" of the list. This is our back door to get at the list object itself.
 
whoa! that might just work
nogo. That doesn't work on my 2.7.9
 
Is there a good canonical dupe for "look at that e-notation on the end of your float"?
 
9:39 PM
I was gonna ask the same thing, but I resorted to linking the poor chap to wikipedia.
 
from functools import reduce
import numpy as np

reduce(lambda a, b: a @ b, [np.array([[1, 1], [1, 0]])] * 10)
 
uuuh might as well just np.linalg.matrix_power(np.array([[1, 1], [1, 0]]),k)
 
^ Doh! Looky here, I just learned about np.linalg.matrix_power
 
don't know how precise that is, though
 
on np.array([[1, 1], [1, 0]]) I'm sure it'll do
for a while at least
I still like the one I partially stole from @pm2ring
def fast_fib():
    a = {0: 0, 1: 1, 2: 1}

    def fib(n):

        if n in a:
            return a[n]

        else:
            k0 = n // 2
            k1 = k0 + 1
            fk0, fk1 = fib(k0), fib(k1)
            a[2 * k0] = fk0 * (2 * fk1 - fk0)
            a[2 * k0 + 1] = fk0 * fk0 + fk1 * fk1
            return a[n]

    return fib
 
user7437554
10:00 PM
any idea about how to replace symbol ' - ' in a column (of a dataframe) in order plot it? I have tried with .replace(-,np.nan) but still the column types are objects :(
 
an MCVE might be in order
for instance, .replace(-,np.nan) should be a syntax error
 
user7437554
im sorry, what I wrote is: df.replace(to_replace = '-', value = np.nan, inplace = True)
 
user7437554
but df.dtypes() shows that replaced columns are still objects
 
@santimirandarp many ways. Results will be dependent on what df is. We can't see your df. dtype of object can still be int or str
Your attempt seems reasonable. If you are still seeing issues, it could be because you have strings. I'd try...
df.apply(pd.to_numeric, errors='coerce').plot()
That will apply pd.to_numeric to each column. When it encounters something it can't convert to a number, it put's an np.nan there instead. That isn't in place though. Make sure to reassign it to df if you want it to persist.
 
user7437554
here is what I tried and an example data: stackoverflow.com/questions/48570481/…
 
user7437554
10:09 PM
@piRSquared right..
 
user7437554
@piRSquared

`df.apply(pd.to_numeric, errors='coerce').plot()` returns: AttributeError: 'module' object has no attribute 'to_numeric'
 
pd.__version__?
it was added in 0.19.0 but we're at something like 0.22
 
If I have x = typing.List[int], how can I get int out of x?
 
@AndrasDeak <--- what he said
 
user7437554
@AndrasDeak 0.14.1
 
10:14 PM
yikes!
python version?
 
I want to abstain
 
user7437554
2.7.9
 
new solution.... upgrade
 
user7437554
how?
 
user7437554
10:16 PM
I think it is upgraded, but the problem might be the debian version (jessie)
 
>>> x = typing.List[str]
>>> x.__args__
(<class 'str'>,)
@Rawing dunder but seems to be the thing ^
 
Hmm, yeah, I wonder if that's the intended way. Did you find that by trial and error?
 
yup, looked at x.__dict__ after not seeing anything in x.<tab><tab> :/
 
@santimirandarp pip install --upgrade pandas
 
I sort of assumed that you're looking at the docs already
 
10:19 PM
In that case I guess I'll post a question on SO
docs turned out to be unhelpful :/
 
cbg. I was wondering if anyone has developed a Django app in Windows that uses numpy in the back end?
I have a situation where I have 3 PCs now all with Anaconda installed and I can build a Django app just fine on all 3 to do what I want, but there's not even a shred of consistency in the PATH between the 3 PCs.
Which tells me I've just brute-forced my way through the issue each time on each PC :P
 
that doesn't sound very numpy-specific ;)
 
user7437554
it hangs on an installation step: Running setup.py bdist_wheel for pandas ... -
is that normal?
 
"hangs"?
are you sure the CPU is not churning silently?
failures lead to errors
 
DSM
You shouldn't need to be rebuilding pandas to install it, especially if (1) you're using Windows, and (2) you're using anaconda.
 
10:30 PM
anaconda would make 0.14.1 less likely, right?
note that I first thought that the pandas setup.py was the django problem, took me a moment to realize there are two parallel discussions now
 
DSM
Oh, wait, I think I crossed the streams..
 
@AndrasDeak the issue is that Anaconda removes my headache of trying to get the scientific stack to work on Windows (otherwise I'd download normal Python and then augment with unofficial binaries) but it doesn't always (and this part I don't understand) add things to PATH correctly
 
DSM
The avatars don't even look alike. I have no excuse.
 
I have it on good authority (h/t DSM) that anaconda is indeed something you want to use
@DSM it can't be us both :P
 
@AndrasDeak so then I think I end up with a situation where I add pip to my PATH, and pip install Django from a binary instead of using conda and then I lose control of what's going on
 
10:32 PM
I haven't used windows in <long time> but my gut feeling is that the same steps on similar systems should lead to the same end result...
Why not install django via anaconda? Is that not a thing?
 
Anaconda is great if you can keep it in the confines of something like Spyder ODE. Once you want to develop an App on it, I seem to keep running into snags and clearly I keep taking different, desparate routes to fix it
 
are you sure you're not down 3 levels in an XYZ... problem which would've been easier mitigated at Y?
 
Yes it is. But installing Anaconda alone won't add it to path now it seems, even if I accept it as the main python installation
@AndrasDeak 3 levels is an understatement. That's why I was interested if anyone has done it properly so I don't keep taking a firefighting approach :P
 
I see :)
well, sort of see
I'm chalking up the rest of my frowns to my lack of windows+anaconda experience
 
DSM
Create a custom environment containing the packages you need. Locate the path to your activate script if you've put it in a weird place. Call it with the name of your environment from the shell. Lather, rinse, repeat.
For example, one of mine lives at c:\Users\dsm\AppData\Local\Continuum\Miniconda3\Scripts\activate.
 
10:38 PM
Also, keep in mind that environments are a python thing, not an anaconda thing. Anaconda just makes managing them easier.
 
DSM
For an appropriately general definition of "environment", of course, because native environments are interpreter-specific but conda environments aren't.
 
@DSM I'm still a bit confused why python.exe, for example, in the Anaconda directory is not added to PATH (even if I tell it to make it the primary python installation). I think this is the starting point of my issues
@DSM ok, that last comment makes things a bit more sensible in the reasoning to me
 
DSM
I seldom click the "add it to the path" button, so I can't comment, I'm afraid, but I agree I thought that's what that would do. I'm pretty sure I've done it in the past and it did what I expected, though.
 
In that case I am abusing Anaconda as a "give me all the packages in Windows" approach rather than using it as a self-contained system.
 
DSM
No, you're right, Anaconda itself is the all-in-one distro. I use miniconda (as you can tell from the path. :-)
 
10:45 PM
I have a feeling in the next week I'll have to go through this all again so I'll make an effort to write down what I did and why. Maybe then I can formulate a decent question rather than looking at 3 different tangled messes :P
 
DSM
I will say that IIRC adding anaconda directly to the path is a deprecated approach (I can't remember the reason, but I think it can get you intro trouble). Much easier just to activate root from your script and then start python.
 
@DSM root? As in, Linux root?
 
DSM
No, root is the name of the "default" environment.
.. or maybe "base", let me check..
 
@DSM then my first port of call is understanding conda environments. I'd be wasting your time to hassle you with this until I've read up further. I think from your previous comments that I understand why environments are a big factor in this.
 
DSM
Fair enough! Just remember that really the only thing special about Anaconda is that they load a whole bunch of packages into the root (or base, still not sure, both seem to work and that puzzles me). It's just one big default env.
 
10:51 PM
@DSM Thanks for your help! :)
 
My 3yr old...

"You shout it out, but I can't hear a word you say. Talking loud, not saying much..."
 
user7437554
is there any requisite to install pandas from pip3?
 
last time you had 2.7.9
 
user7437554
with sudo pip3 install --upgrade pandas there is no progress in the installation
 
user7437554
yes I have python 2.7.9
 
user7437554
10:54 PM
and also 3
 
user7437554
as kernels in jupyter-notebook
 
user7437554
python 3.4.2
 
Two remarks: sudo installing with pip is discouraged, because it will execute malicious code for you if you install the wrong package. And it's best to use the python version you want explicitly via python3 -m pip install ...
instead of sudo installing you should either install with --user, or use a virtualenv
 
user7437554
i don't know what are you talking about
 
user7437554
few days using all this
 
10:57 PM
How do you have such an old version of pandas if only using it a few days?
 
user7437554
I installed it today..i don't know @piRSquared
 
user7437554
just wrote sudo apt-get install python-pandas or somehing like that..
 
was going to say that ^
stable repos are usually pretty stale
 
Haven't used Linux in a bit, I can't speak to best way to install Anaconda. But I'd venture to guess that you could just go to the website, download and click something.
 
user7437554
I wrote: python3 -m pip install pandas and got same version
 
11:00 PM
again: anaconda and non-anaconda are two different problems
 
user7437554
I don't use anaconda, too messy (not sure if the word is corect)
 
user7437554
So, I am stuck. Damn..
 
user7437554
But thanks..
 
I'll be clear. My advice will only go so far. I use Anaconda on windows (And Mac). As for the original question. pd.to_numeric will work on any system so long as the version of pandas > 0.19.
I just don't know what to tell you that will get you there (pandas > 0.19)
 
user7437554
yes, thats great. But I cant install it
 
user7437554
11:02 PM
there where?
 
user7437554
oh..I need to upgrade to debian stretch but I cant for some reasons
 
upgrading your debian in order to ugrade pandas is....overkill to say the least
 
user7437554
What I tried (that with .replace) replace the - symbol but columns were still objects
 
user7437554
@AndrasDeak yes but I think there are many outdated packages..
 
DSM
The whole thing seemed to go swimmingly for me even using the system python (see here).
 
11:06 PM
@santimirandarp stretch won't solve that. Learning how to use pip will solve that.
 
You could also attempt df.replace('-', np.nan).astype(float)
But that will break in many circumstances
 
user7437554
@AndrasDeak what should I learn? I tried the command to install, and to upgrade, pandas..
 
Here's an idea: can't pandas.read_csv just handle those minuses in the data as nans to begin with? Of course you'll still have to upgrade
@santimirandarp oh, my bad
I guess that's that ¯\_(ツ)_/¯
 
@santimirandarp try:

df.convert_objects(convert_numeric=True)
 
user7437554
(I am doing it just to learn, just want to say that)
 
user7437554
11:09 PM
@piRSquared good, I will try
 
that is a deprecated method that might work for your version
you may still need to use replace ahead of it
 
DSM
The first step is learning how to make and activate a virtualenv, and getting pip working inside it -- working with out-of-date pandas is just going to lead to frustration, IMHO.
 
if you want to hand them a solution (which might be fine) you should look at their MCVE to avoid jumping through unnecessary hoops
 
user7437554
I can hardly learn to write some code, it is not easy to learn everything @DSM
 
good luck anyway
 
DSM
11:13 PM
@santimirandarp: I agree, it's not easy to learn everything, but if you want to play around with pandas getting pandas installed seems like an important first step. :-) As Andras said, good luck, though!
 
user7437554
Ok. So I should see a video on youtube about set environments or what? (I know you are trying to help @DSM)
 
user7437554
pd: are you sure that virtual environment using debian jessie allow install updated pandas?
 
DSM
I'd start by reading the official tutorial, and making sure you can follow it.
 
user7437554
@DSM right.i will start now..
 
and yes, a virtualenv has a specific python version (the one you created it with) but the whole point is to give you an isolated set of modules (i.e. an environment) to work with
 
user7437554
11:21 PM
@piRSquared i tried df.replace(to_replace = '-', value = np.nan, inplace = True) and
df.convert_objects(convert_numeric=True)
 
user7437554
but didnt work. Same error of the post
 
user7437554
cool..@AndrasDeak
 
wim
 
thank you (-:
 
aww, what is that? A pangolin?
 
11:36 PM
Yes
 
looks like it
 
DSM
Way past end of work day. Rhubarb for all!
 
Rbrb @DSM
 
rhubarb
 
00:00 - 18:0018:00 - 00:00

« first day (2665 days earlier)      last day (2276 days later) »