« first day (2356 days earlier)      last day (2591 days later) » 

12:04 AM
@AndrasDeak still waiting?
 
DSM's, yes
but there probably won't be one
 
DSM
Oh, no plot twist. It was horse, not zebra.
 
thank goodness for google
 
DSM
The most interesting plot twist on Nyte's side would be that he forgot to mention that he set random.seed(3060364) or something.
 
or that something threw an exception as an aside, which interfered with closing the file on account of the printing lacking a context manager
 
12:14 AM
actually the plot twist is that im just an ape that scientists are doing research on
 
12:39 AM
Let me acknowledge how stupid the term "animal husbandry" is.
 
1:08 AM
rhubarb
 
1:28 AM
Also downvote so we can then delete. I've already flagged it.
 
 
2 hours later…
4:14 AM
Cabbage :-)
 
 
2 hours later…
5:56 AM
cbg
 
6:23 AM
cbg
 
6:40 AM
@Grimlock I'd recommend anything that is easy for APIs as well as easy for you to learn & quickly implement.
 
7:15 AM
40% progress towards my Fanatic gold badge.
 
7:51 AM
Cabbage
 
8:22 AM
Cabbage
 
 
1 hour later…
9:37 AM
Morning all.
 
10:16 AM
@ZeroPiraeus "rude or abusive" flags will nuke gibberish posts from the site (along with a -100 rep penalty to OP)
For intentional garbage that's the most effective
and cbg
 
strong entrance andras
 
Nuked his way in.
 
*Ariel hair flip*
 
awwww :)
afghans are awesome
 
10:34 AM
High maintenance, just like you! ;)
Aunt has a Saluki. The most enormous dog.
 
I've never seen one:)
I mean a saluki
 
11:16 AM
I know this isn't a great question, but I feel that Tigerhawk was a bit heavy-handed here. Sure, SO isn't a tutorial service, but the OP isn't asking for fully-fledged tutorial, they just need help in understanding why their algorithm doesn't perform as expected.
Yes, it's an inefficient algorithm, but that's not the point. An answer that explains the flaw in their algorithm and shows how to fix it could also show a better way to do it. Merely saying "you're doing it wrong!" and dupe-hammering isn't really helping them learn, IMHO.
 
11:37 AM
fortunately Stack Overflow is not a tutorial service, so OP's learning curve is irrelevant :P
he's right that a question asking for removing dupes in a string is a dupe
plus OP is using tabs for indentation...
and the answers they did get ignored their learning curve too, they just give them a new method to solve the same problem -> dupe
 
quick question
let's say I have this
ham = {'no' : 8,'color' :'blue'}
 
@AndrasDeak I suppose so, except the OP isn't asking for the best way to do it. They're exploring alternative approaches, and I think that's a good thing, although it can lead to inventing stupid ways to do stuff, as I alluded to in my comment. Yes, you should use the "batteries included" that come with Python, but OTOH, it's reasonable to avoid using them when you're trying to learn about recursion.
 
yeah, I understand your point
 
for keys,values in ham.items():
    print(keys + ' - '+ str(values))
 
but I also understand TH's one, and he's not really wrong either
 
11:44 AM
I will have everything set on a line by line basis
 
compared to his usual occasional "blatantly wrong", this is something :P
 
no - 8
color - blue
How would you do to have everything set as this
no - 8, color - blue
 
use the kwargs of the print function
 
I tried this
 
or join your bits with ,
', '.join(' - '.join((keys,str(values))) for keys,values in ham.items())
 
11:46 AM
@AndrasDeak Fair enough.
 
wow
 
for keys,values in ham.items():
    print(keys + ' - '+ str(values), end=', ')
print()
 
what do you mean by kwargs @AndrasDeak?
 
the latter, but you'll have a trailing ', ' which you have to treat (i.e. you'd probably have to print ', ' at the beginning starting from item 2 or something)
I'd definitely go with double join
 
user6845426
cbg o/
 
11:49 AM
cbg
 
\o
@AndrasDeak why the extra print() please?
 
because it was a handwaving example:P
you'll need a final '\n' at the end
otherwise it would muck up your terminal output
 
I'd use the format method on each key, value pair:
', '.join(['{} - {}'.format(k, v) for k, v in ham.items()])
 
right, that's great for implicit str()-ing ^
and I think you can use a genexp inside the outer join
with implied parentheses
 
Or the f-string way:
', '.join([f'{k} - {v}' for k, v in ham.items()])
 
11:52 AM
meh, that's actually more redundant
 
@AndrasDeak You can, but you shouldn't. :)
 
although I know that should be more efficient
@PM2Ring how so?
I thought this would be an ideal place for a genexp: single-use iterator that gets consumed by join
 
@AndrasDeak @PM2Ring there are many ways. Why should you go with one instead of another? Are there one, which is more efficient than the other in term of IO?
 
.join has to scan the strings twice, once to determine the full length of the destination string, and then a second time to copy the strings. If you pass it an iterator it has to build a list. So it's better to just give it a list in the first place.
 
@AndyK there is always one, and preferably only one obvious way, so you can choose to your liking :P
@PM2Ring oh, I had no idea! thank you
 
11:55 AM
it feels like some mysterious path like in Kung Fu, the tv show. Only when you enlighten, you will get it
 
Of course, if you need to feed some other iterator to .join, feel free to do so: it's pretty efficient at making a list. But if it comes to a choice between using a gen exp or a list comp, pass .join a list comp.
 
yeah, sure
 
@AndrasDeak FWIW, that was one of the first things I learned from Martijn.
 
:)
that's cheating
 
I only steal from the best. :)
 
11:58 AM
going back with the intern. see you a bit
 
have fun;)
 
Did that BMP stuff from Sylent Nyte get resolved? From my quick read-though of the transcript it wasn't totally clear... And I never did understand how come there were 8 bytes in his file when he was writing 4 bytes...
 
It's weird how what I know about python is arranged in a pattern that probably resembles Lévy flight patterns
 
Hey, it must be an efficient hunting strategy or they wouldn't have evolved it. :)
 
Anybody used Solr , i am having problem in that
 
12:12 PM
@TheExorcist Posting your question right away might increase the likelihood of a response and reduce the time taken.
 
i need to remove apostrophe from the words before indexing. For eg I want Bachelor's to become Bachelor . I used solr.ApostropheFilterFactory for that , but this filter got deprecated after solr4 and i am using solr5
 
I think it is specific enough and would be a good choice on SO instead of chat.
 
I can't even google soir :P
 
i searched on SO, but found nothing.
 
lol, it's not soir, but 'SOLR'.lower()
I saw too many French today
 
12:19 PM
@AndrasDeak i was expecting answer.,plz help me in finding answer.
 
druid magic or black magic: which one do you expect me to use?
 
@AndrasDeak me too, saw and still seeing too many French :))))
 
user6845426
Druid
 
user6845426
always
 
I'm leaning towards druids because animals are cute
 
user6845426
12:20 PM
^
 
@AndyK I figured;)
 
@TheExorcist I assume you're using Solr via some Python library...
 
no currently i am working directly on solr local .
 
assertion failed
 
@TheExorcist So in what way is your question connected to Python?
 
12:23 PM
if it would be solr 4 i wont be having problem but now library is deprecated , lolz @AndrasDeak yeah i accept , my assertion failed.,
@PM2Ring because i will be converting it into n-grams type before the process involves solr
 
no, it was PM's assertion that failed
you can stop pinging me now
 
user6845426
How do I reshape a list to x many collumns and 1 row?
 
@TheExorcist In that case, why can't you remove the apostrophes using standard Python str methods, like .replace or .translate?
 
@dipper "columns" as in nested list?
[1,2,3] --> [[1],[2],[3]]?
that's the numpy interpretation
and it's either np.reshape(inp,(-1,1)) or [[k] for k in inp]
 
user6845426
Yeh, I've done horizontal projection so I'm trying to print out the resulting list with just 1 row so its easier to visualise
 
12:29 PM
wait, 1 row with x columns is exactly a list :|
 
Because the process goes like this , we index the pages to solr server , after getting indexed , python role comes ,Yeah you are right PM2RING .But i need to remove while indexing.
 
what do you mean exactly, @dipper?
What is your input? And I mean type and shape.
 
user6845426
Ive used docs.opencv.org/2.4/modules/core/doc/… function which returns the sum of all pixels in each column
 
user6845426
So, my input is an image
 
opencv returns numpy arrays I believe
 
12:31 PM
@TheExorcist Sorry, I can't help you. I know nothing about Solr. And your question is off-topic for this room.
 
outp.shape is (N,1), correct?
 
user6845426
(1, N)
 
that's a row :P
it's equivalent to [[1,2,3,4,5]]
a list within a list
so......outp[0], hmm?
or outp[0].tolist() if you really want a list
 
user6845426
I know. In my console, the result is printing rows of 14. I just wondered if I could change so the console prints the list on one line. Makes it easier for me to vis
 
have you considered the possibility that you have 500 numbers in that row and the line is being wrapped?
>>> np.arange(30)
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29])
^ that's a row
you can use numpy.set_printoptions to manipulate how printing behaves
but if you convert to a list and print, it'll be on one line
>>> np.arange(30)
array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
       17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29])
>>> print(np.arange(30))
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 25 26 27 28 29]
>>> print(np.arange(30).tolist())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
 
12:36 PM
cbg
 
cbg
 
user6845426
Yeh i'm guessing its being wrapped
 
user6845426
I worded my question wrong
 
12:38 PM
hello
 
user6845426
Thanks all the same though
 
no worries
 
user6845426
I guess thats enough work for the week. Unwrapping a list :D
 
if it doesn't fit in your terminal, print to a file
there really aren't other options
 
user6845426
Yeh it did fit in the terminal. I just used .tolist()
 
user6845426
12:42 PM
It doesn't make any difference in the way I process the list, I just wanted to visualise it too see if the results were as expected
 
OK:)
 
I must be missing something obvious reading from this csv file...
https://gist.github.com/anonymous/5c0a72cb9bd369a1676d9157f6371d4d
File name prints and then I get: `FileNotFoundError: File b'3_01.01.16 to 06.30.16.csv' does not exist`
 
should that really be a bytes?
 
idk, that's how I always read csv files with pandas
Though, reading them from a zip file is new to me
 
pandas.read_csv(filepath_or_buffer, ...)
filepath_or_buffer : str, pathlib.Path, py._path.local.LocalPath or any object with a read() method (such as a file handle or StringIO)

    The string could be a URL. Valid URL schemes include http, ftp, s3, and file. For file URLs, a host is expected. For instance, a local file could be file ://localhost/path/to/table.csv
 
12:46 PM
for file in myzip.namelist():. Is file a file, or a file name?
 
the error suggests that it's a file name as a bytestring
I'd try .decode-ing it
 
If it's a filename, then I expect read_csv to take the filename, look for the filename in the current working directory, not find it because it's in the zip and not in the current working directory, and raise a FileNotFoundError.
 
oh that's what you mean ^
it's weird because the pandas docs only mention str, not bytes, but they're probably 2-3 agnostic
 
morning everyone
 
cbg
yeah, Kevin's probably right, again
 
12:49 PM
Presumably the zipping module you're using has some way to get a file-like object of a file in the zip, in which case you only need to pass that into read_csv instead of the filename.
 
@PM2Ring ty for help, i have created question on SO.
 
ZipFile.open might help
rhubarb for now
 
I agree. Something like df = pd.read_csv(myzip.open(file),encoding='ISO-8859-1',low_memory=False)
And for clarity's sake I suggest renaming file to filename
 
aha, thank you so much guys
 
user6845426
I have a list that I'm trying to loop through which is the result of using the `reduce()` function.

I'm using `for count, (current, nextCo) in enumerate(pairwise(result), 1):`
 
user6845426
12:55 PM
Pairwise being:

def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return izip(a, b)
 
user6845426
For some reason, when I try and print count within the loop, it's returning emtpy
 
result = [1,2,3,4]
for count, (current, nextCo) in enumerate(pairwise(result), 1):
    print(count)
#result:
#1
#2
#3
Works for me. Please provide a value for result that demonstrates your problem.
 
user6845426
oh really
 
user6845426
2 secs
 
guys what do if another developer is not communicating what he is working on well, and we're working on the same project?
 
1:02 PM
I stop looking in the mirror
 
I know to use pythonw.exe if I don't want the cmd window showing up in Windows but I also don't want the focus to change away from what I'm using when I run the script (which runs via shortcut)
 
kevin with the snappy comeback
 
Define "runs via shortcut". If you're double-clicking a shortcut icon on your desktop, I'd expect whatever window you were working in to lose focus, because you double-clicked on the desktop.
 
user6845426
my result is of shape (1, 1060) im baffled
 
That happens even before the Python process starts so there's not really anything Python can do about that
 
1:05 PM
@Kevin I'm using a keyboard shortcut
 
So, like, Windows-R...?
I would expect that shortcut to also cause the current window to lose focus, and give focus to the "run..." window
 
No, I have an actual shortcut file and then I execute that shortcut file by typing Ctrl + alt + W
 
user6845426
 
the 'actual' shortcut file is what calls the python script via pythonw.exe
 
@dipper I have no idea what that is, but if it's anything like a list of lists, then it's not surprising that print(count) doesn't display anything, because it's only one element long, so pairwise yields nothing.
Consider the simpler example of result = [[1,2,3,4]]. Also produces no output.
For precisely the same reason that result = [1] produces no output
 
user6845426
1:11 PM
Can I unwrap it to a single list?
 
user6845426
The gist was the return from reduce() which reduces the image matrix to a single 1d vector
 
If result was a list of lists, yeah, you could unwrap it. I don't know what a vector is, so I don't know if you can unwrap one of those.
If by "can I unwrap it?", you mean "would unwrapping it help?", yes.
result = [[1,2,3,4]]
result = result[0]
for count, (current, nextCo) in enumerate(pairwise(result), 1):
    print(count)
#result:
#1
#2
#3
 
user6845426
ah thats perfect
 
user6845426
Thanks @Kevin
 
@clickhere Can't say I'm familiar with that shortcut, unfortunately. It doesn't seem to do anything on my own machine.
Google seems to indicate that it opens a user-specified file, but it doesn't mention how to specify what file to open
 
1:17 PM
it's a custom shortcut. But it calls the shortcut file which has the target set to run my python file with pythonw.exe
 
@dipper I guess tee is reasonably efficient for that use case, since the two iterators are almost in sync (if they can get out of sync tee can chew up a lot of RAM). But I'd probably just write my own generator.
def pairwise(iterable):
    it = iter(iterable)
    prev = next(it)
    for curr in it:
        yield prev, curr
        prev = curr
 
user6845426
Oh really? Thanks :)
 
No worries. :)
 
I'm lazy and just do return zip(a, a[1:]) even though it only works on slice-able types and it needlessly consumes O(N) memory.
 
\o cbg :D
 
1:22 PM
@Kevin I do that too, when a isn't huge - it's probably faster than setting up & calling a genny.
 
user6845426
cbg o/
 
And for non-sliceable things there's always islice
 
islice and izip get you back down to O(1) memory, I think. I'm guessing it still doesn't work on objects that can only be iterated once
 
And of course if you want to iterate over something a pair at a time, you can do
def pairwise(iterable):
    it = iter(iterable)
    for curr in it:
        yield curr, next(it)

for t in pairwise(range(8)):
    print(t)

#output
(0, 1)
(2, 3)
(4, 5)
(6, 7)
@Kevin Indeed.
 
cbg
 
user6845426
1:35 PM
cbg :D
 
user7098858
hi python lovers)
 
cbg o.o
 
What's the right way to acheive this effect? df+str(i) = pd.DataFrame() <<exists in a loop
 
Use a dictionary. my_dict[i] = pd.DataFrame()
Or, if i is a sequentially increasing series of integers starting at zero, use a list. my_data_frames.append(pd.DataFrame())
"Dynamic variable names" is 99.9999 percent of the time, the wrong approach
 
I'm interested in hearing about that .0001 percent of the time
I think the intersection of "languages without first-class dictionary support" and "languages that have dynamic variable names" is an empty set
 
1:50 PM
Like if you're interfacing with a truly horrible API that expects certain names to be at the global scope, instead of doing something sane like accepting parameters
 
Even then, the correct approach is finding a new job
 
Most use cases fall under the umbrella of "having no choice but to work with existing code that already uses dynamic variable names"
 
ok so something like:
>>> df=[]
>>> for i in range(1,3):
df.append(pd.DataFrame())


>>> df[1]
 
That would work just fine! But if you're just making 2, you might as well write it manually :P
 
@KevinMGranger just an example. the amount is unknown
 
1:54 PM
Hi
 
That code will work, but to be clear, df[1] will be the second frame in the list, and df[0] will be the first.
That's why I specified "starting at zero"
 
right, so then there's no appropriate way to get my preference of having variables named df1,df2,df3 etc..?
 
Is it really important to you that you be able to do that without [] and 1-indexed instead?
 
There's no point in doing that, because if the amount is unknown, you won't know what numbers you need to put in the variable names while you're writing the code
 
I've used once virtualenv while I was developing a toy program, now I would like to use it again, since it's a nice way not to clutter my global Python environment, but I would have a question: once you're finishing developing in a virtualenv, and, say, you want to make your packages available in pipy (as beta, or whatever), how do you usually do it?
 
1:56 PM
If you want the answer to your specific question, you can do some magic. That will be some confusing code. Using a list is definitely the Rightâ„¢ way to do it
 
it's not really important. Though, I think I'll make mistakes when reading in dataframes via this method since I rarely approach dfs this way
 
If you really insisted on having dynamic variable names, you'd run up against situations like "Ok, now I need to frob the value of df-something, but I don't know what something will be until the code is actually running, so I need something like frob(df+str(n))"
In which case your code is actually less concise than using a dict and doing frob(df[n])
 
and df usually refers to a single dataframe, I suggest calling a collection of dataframes something like dfs
but that might just be me...
I like to pluralize my complex containers
 
Yeah, I always always always pluralize the names of lists.
 
also, recbg
 
1:59 PM
What about when you have a list of an uncountable noun, and you need a name for the iteration variable :o
for __ in fish:
 
Is this too snarky?
@Mr.Xcoder Good call. But it's not clear exactly what the OP is doing, since this code appears to have at least one indentation flaw. Shame they couldn't post the error Traceback... I guess their computer's melted or something... — PM 2Ring 7 mins ago
 

« first day (2356 days earlier)      last day (2591 days later) »