« first day (3129 days earlier)      last day (1834 days later) » 

12:25 AM
does anyone know what variation of Radix is fastest on 2 million 32bit ints
anything faster than the LSD variant.
 
12:47 AM
hello, sorry if this is a basic question but I'm looking at documentstion for command line and it shows something like this

python -m spacy convert [input_file] [output_dir] [--file-type] [--converter]
I'm not sure what the double dash means in front of the paraneters
Do I include them in front of the option for example

python -m spacy convert train.txt output --json --auto
or like this

python -m spacy convert train.txt output --file-type json --converter auto
 
1:05 AM
nevermind figured it out, never saw double dashes before, usually just single dash like python -m etc...
 
 
3 hours later…
3:55 AM
Hi guys, I always wonder what "Add launcher to dir path" in pycharm installation mean. What it the purpose of it?
 
 
2 hours later…
5:55 AM
I create a virtualenv and activate it and get a "pip freeze --local" and it has five packages (e.g. youtube-dl), why? shouldn't a fresh environment be empty of any non-main packages?
 
 
2 hours later…
8:22 AM
@Moytaba unless you created the virtualenv with --system-site-packages, it should be empty
 
9:08 AM
@wim Thanks for the answer
 
 
1 hour later…
10:37 AM
hmm, one other thing that could have happened is that you set up the virtualenv with --no-pip and the pip freeze is executed by a globally installed pip.
 
user6718998
Hi there. Presuming I have such collection: [array([442, 687]), array([480, 790]), array([495, 791])] how can I extract first column like: 442, 480 and 495 ?
 
[item[0] for item in my_collection] in a list comprehension
Is there a reason that you have a list of arrays and not a 2D array? Are these numpy arrays?
 
user6718998
yes, numpy
 
If you had a 2D array, you'd use my_collection[:, 0] to slice the first column, but you can't do that if you have the arrays in a list
 
user6718998
I noticed that.. my initial data structure is a dict though, like: {'0': [array([442, 687]), array([480, 790]), array([495, 791])]}
 
user6718998
10:50 AM
And I am trying to do scatter.plot
 
user6718998
plot.scatter**
 
What creates that dictionary?
 
user6718998
it's some algorhithm for clustering
 
user6718998
in that dict 0 is a variable 'k' and I try to plot like: for k in range(k): plt.scatter(clusters[k + 1][:, 0], clusters[k + 1][:, 1], c=color[k], label=labels[k])
 
user6718998
but because of numpy arrays it doesnt work
 
10:53 AM
I'm not so sure it's because of the numpy arrays here but rather the structure that the library returns. Still, it's probably easier to extract the values with list comprehensions as I showed vs. trying to make a more sensible structure
You're looking for something like this?
import numpy as np

import matplotlib.pyplot as plt

data = {'0': [np.array([442, 687]), np.array([480, 790]), np.array([495, 791])],
        '1': [np.array([442, 500]), np.array([480, 700]), np.array([495, 800])]}

for k, v in data.items():
    plt.plot([item[0] for item in v], [item[1] for item in v])

plt.show()
 
user6718998
This is a quite good solution
 
12:46 PM
@Thewise array2d = np.array(data['0']) assuming they're all the same size. Otherwise you can only use a list comp
(and then slice the first column of course)
arguably your data should already be a 2d array before being put in the dict
also if you have a dict where keys come from range(len(dct)) you really need a list
 
1:09 PM
good morning, I managed to sleep in until 6 am this morning
I'm still feeling off from 7 days at PyCon
Really felt like 1 giant day, not 1 week
 
cabbage
 
3 hours ahead cabbage
Or as GitHub kept telling people who didn't change their timezone: sent 12 hours from now
 
1:26 PM
hehe, timekeeping is hard
was the conference fruitful?
 
definitely. ran 4 open spaces, attended a ton more, maintainers summit, psf lunch, 3 days of sprints with 200+ notifications waiting for me
also lots of food and drinks with people. So much walking
 
Sounds awesome :)
although that notification count sounds a bit overwhelming
 
2:20 PM
@ParitoshSingh: You there?
 
2:33 PM
i am now
why, wassup
 
I was re-reading yesterday's converstaion about id-comparing and kind of made my notes. I would like to clear my doubts for these- chat.stackoverflow.com/transcript/message/46184524#46184524
stackoverflow.com/questions/36898917/… - states that small integers will re-use the same instances
 
yes, for the sake of efficiency, python keeps a cache of small ints
 
ok
 
that is an implementation detail though, you shouldn't have to know about it in normal usage.
i dont even know if non cpython implementations enforce it.
 
so mistermiyagi was saying the same (what you just said) here - whereas int = {..., -1, 0, 1, 2, 3, ...}
 
2:41 PM
yeah, the idea being there's infinite different possible objects for the int class that can be made.
 
ok, thanks...that was it!
{ -5, -4.....0, 1, 2...255 } might use the same instance
 
in cPython atleast, yeah.
upto 256 iirc
 
Yes, all clear now :)
 
cool cool
 
:P
 
2:54 PM
Anyone on Windows 10? Can you repeat this issue?
I'm on 7 and it seems it would have to be a very deliberate effort to change the encoding of cmd, but I can't test on 10
 
oh wow
can confirm here, its all ?
>>> os.listdir()
['badnametest', 'html.html', 'outscript.py', 'נצר מטעי מעשה.txt']
via cmd prompt
but whats funny is, that apparently i can paste it ^
 
This is on Windows 10?
 
What have they done? :/
 
it looks like question marks on the display
no idea haha
let me try spyder, sec
yep, spyder handles it perfectly well
something about the cmd, or windows defaults on win10
 
3:06 PM
mmmm, I'm not sure even where to start with that one
 
whats more confusing to me is that if i copy paste it, its correct. why is that?
fwiw, i tried this
In [6]: with open("testout.txt", "w") as f:
   ...:     f.write("נצר מטעי מעשה")
   ...:
and again, here it looks fine. in the cmd it looks like ??? and does this:
UnicodeEncodeError                        Traceback (most recent call last)
<ipython-input-6-d6dd04880156> in <module>
      1 with open("testout.txt", "w") as f:
----> 2     f.write("נצר מטעי מעשה")
      3

C:\ProgramData\Anaconda3\lib\encodings\cp1252.py in encode(self, input, final)
     17 class IncrementalEncoder(codecs.IncrementalEncoder):
     18     def encode(self, input, final=False):
---> 19         return codecs.charmap_encode(input,self.errors,encoding_table)[0]
     20
     21 class IncrementalDecoder(codecs.IncrementalDecoder):
^ really trippy to look at, considering it shows up just fine in the text file
 
Encoding tries its best to top my list of most annoying things, but datetimes still cling on
 
3:22 PM
unicode-characters-being-replaced-by-question-marks-after-copy-and-pasten ->windows 10 - >https://superuser.com/questions/1166350/unicode-characters-being-replaced-by-question-marks-after-copy-and-paste-on-wind
 
I also lied, apparently. I get the same ? in cmd with 7 as you did with 10, it's Spyder fixing it for me
 
3:34 PM
stackoverflow.com/a/56079149 "how do I use Jinja templates to render a table" "write individual lines of html to a file instead" this is just bad advice
 
what is delv sorry
 
Vote to delete
A privilege that neither of us have yet
 
im guessing that's an option that opens up at higher rep
regardless, this is an answer. whether good or bad, that should be dictated by votes right? i'd imagine bad answers dont quality for del votes, if they are sincere attempts to answer
atleast, ive been told off for flagging an answer once along similar lines.
 
no, this is absolutely an awful answer
the whole point of the delete privilege is to use it to clean up things that shouldn't be there, and this shouldn't
 
i see. i'll take your word for it
 
3:40 PM
The problem is that somehow the op thinks this is good advice, but it's so far off base they're actually worse off now.
 
user7437554
Hi guys, is there a way to plot 2 columns of a pandas df as x,y arguments in pyplot.plt?
 
user7437554
#column10=data1.iloc[:,[0]]
#column11=data1.iloc[:,[1]]

plt.plot(x=column10, y=column11)
 
user7437554
I've tried that, with no success
 
user7437554
Found it
 
A comment or another answer would probably be better than deletion
 
3:59 PM
I already had a comment convo with them.
But "I know this should be deleted" does not imply "I should answer this"
 
I was hesitant to delete because deleting answers is usually reserved for glaring NAA/VLQs over technical inconsistencies... But it seems you've already given advice that has fallen on deaf years so I'm more at ease... Cast my vote
 
user7437554
Guys if you have a value v=20,000
 
user7437554
How would you convert it to v=20.000?
 
Convert how? For visual purposes?
 
4:15 PM
as in v / 1000?
 
@Arne thank you for your answer. 0/
 
4:34 PM
@santimirandarp v=20,000 is a tuple in python. Please be clear and unambiguous.
 
user7437554
@AndrasDeak & co pastebin.com/FL1LLBxd
 
user7437554
i've made a short example of what I'm trying, on the link
 
user7437554
I haven't done this before so you might find a weird way to plot the data
 
the paste says your problem is a UnicodeDecodeError
which problem are you trying to solve?
 
user7437554
Yes, what is it?
 
user7437554
4:43 PM
I don't know where does it come from
 
the first line with a bunch of unicode characters?
tell read_csv that there's a header line
 
cbg
 
cbg
 
your file is not utf-8 encoded
 
How should I capitalize python? Python or python?
 
4:45 PM
@MisterMiyagi it says "ascii codec" can't decode
you could probably tell it to use unicode but that's Y in the XY problem
unless pandas is smart enough to use the unicode header line...no idea if so
 
user7437554
I've tried to plot from the second row and it's the same error..., that's why I suppose \theta had nothing to do
 
Pandas still has to read the file
even if you do not plot everything
 
user7437554
I see, thanks. So what do you propose?
 
@AndrasDeak seems like the recent SO questions gave me a muscle memory for UnicodeDecodeError :/
10
Q: How to read UTF-8 files with Pandas?

IstvanI have a UTF-8 file with twitter data and I am trying to read it into a Python data frame but I can only get an 'object' type instead of unicode strings: # file 1459966468_324.csv #1459966468_324.csv: UTF-8 Unicode English text df = pd.read_csv('1459966468_324.csv', dtype={'text': unicode}) df.d...

 
4 mins ago, by Andras Deak
tell read_csv that there's a header line
 
user7437554
4:51 PM
I've tried header=[0], but I guess its wrong
 
> Default behavior is to infer the column names: if no names are passed the behavior is identical to header=0 and column names are inferred from the first line of the file,
OK, so pandas is smart enough and you really need the encoding as Miyagi said
 
user7437554
So non utf8 characters must be removed?
 
Why would you even think that?
just read what Miyagi has said........
Also "non-utf8 characters" are rare
I think I'll just go back to napping for greater good
 
 
2 hours later…
wim
6:47 PM
Any thoughts on duping casting raw strings python onto -> Convert regular Python string to raw string? The former has more votes, but all of the answers are bogus/downvotable.
Approaches suggesting to (ab)use unicode escape for this have weird edge cases and failure modes. It seems @Aran-Fey has been using that as a dupe target for some time but it's a fundamentally broken idea (and misguided question), and I'd like to reduce the visibility of that kind of "solution".
 
7:09 PM
last time I checked the "raw string" situation was a huge mess that wasn't really fixable without nuking all existing questions and replacing them with self-answered ones, so... I don't really care what happens to the existing questions
that said, I think casting raw strings python is probably the only one of those that has a clear problem statement - with this string as input, produce that string as output. It doesn't really have much to do with raw strings and it needs a better title and it's a super niche problem, but it's a reasonable question
 
wim
If you think it's a reasonable question, what should be the output for an input "\a"? Should it be "\\a" or should it be "\\x07" or...something else?
O.P. was last seen Mar 29 '10, so there's not really any hope of them clarifying..
 
why does it work the way it does?
 
wim
It seems to me this is the only correct answer, as unsatisfying as that may be to confused OP's.. (and that suggesting a round trip via unicode escapes will just further confuse them and reinforce misunderstanding)
 
what if OP is not the one responsible for the original string that should have been treated as raw but wasnt?
we often have to deal with someone else's mess too, and thats a very common problem with encodings in general. i can see it applying here too
 
7:25 PM
@wim Meh, I don't think that's a big deal. Would you prefer to have 2 separate well-defined questions that are 90% identical but one asks for the output "\\a" and the other asks for "\\x07"? I think an answer that explains the ambiguity would be best
 
wim
@ParitoshSingh I can not think of any legitimate use case where you might want to generate a raw string representation. I mean, what can you even do with that? Put an "r" on front and then eval it? Even if you could figure it out (and you were happy to just choose one of the many possible representations), you'd just be back where you started
 
yeah, i dont know what usecase would there be. The only one i can think of off hand is something that was supposed to be used to regex match patterns, but got mangled because it wasnt raw string escaped.
and i dont even know how that would work out tbh
 
wim
Guess I am disagreeing that this is "a reasonable question" and intend to discourage that it should be used for dupe target going forward.
@Aran-Fey what is the "super niche problem" you mention?
to get to +30/-0 votes and 15 favourites, there must be some popular use-case out there, but I can't for the life of me figure out what it might be!!
 
converting "hurr..\n..durr" is the super niche problem r"hurr..\n..durr"
I'll leave that like that as a monument to how tired I am right now
 
./pats on head
 
user7437554
 
user7437554
any idea why the points are connected like that?
 
@santimirandarp they aren't sorted according to x
inds = data_x.argsort(); data_x = data_x[inds]; data_y = data_y[inds]
 
user7437554
exactly, but I couldnt find an option to do that
 
even easier for a 2d array
@santimirandarp it's not an option
 
user7437554
oh, its quite complicated...
 
7:47 PM
no, it's not, you just have to sort your data
 
user7437554
Well yes, but then the indexes must be rearranged...
 
numpy version of data_x,data_y = zip(*sorted(zip(data_x, data_y)) or something like that
@santimirandarp if you have a dataframe you should sort the rows, probably. Perhaps pandas has a tool for this for plotting, I don't know
 
user7437554
I see, thanks...
 
wim
@Aran-Fey hmm, I really meant what is the higher level problem which prompts user to give "hurr..\n..durr" -> r"hurr..\n..durr" as an example.
 
that I do not know :D
 
wim
8:01 PM
maybe there is some legitimate use-case in regex source code generation but I doubt it's what the 30 upvoters needed .. :)
 
 
1 hour later…
9:23 PM
Need to see an implemetation of a producer-consumer code, with a special case: when a producer signals consumers to stop consuming, it may or may not also indicate that remained tasks must be consumed. Know of any such implemetation? Doesn't have to be in Python
 
9:44 PM
dont "know" of one, but sounds doable
 
 
1 hour later…
10:50 PM
Someone knows how to interpret the prediction of a linear model? I receive a numpy array of floats and I'm confused
 
MCVE please
Or at least framework+function
 
11:15 PM
I hope this is not about your similar question from April with an accepted answer stackoverflow.com/questions/55840486/…
(Unless it's different enough to merit asking)
 
11:47 PM
Yes, it is exactly it, I shouldn't have marked it as correct by then, the solution gives me weird results.
 

« first day (3129 days earlier)      last day (1834 days later) »