« first day (2972 days earlier)      last day (2201 days later) » 

00:00
@shad0w_wa1k3r no I'm cool. you already explained it :), behaves as expected. that last statement was posted in the wrong room by accident
np
time to retire for the day and hope tomorrow I'll sleep on time :-p
rbrb
wim
wim
@AndrasDeak no, I guess not :)
as a general guide, __iadd__ should be implemented for mutable types and should return same instance, __iadd__ should not be implemented at all for immutable types, although nothing in the datamodel enforces that stuff
00:31
I could live with that
01:13
Also FYI, here is DataCamp's "18 Most Common Python List Questions", some may be worth crosschecking against our canonicals.
01:40
@AnttiHaapala I understand your point of view. But in 1) I have specifically asked for a function that can help load partial data into a plot and then load data acc to input given. With the sample code given, I think it's reasonably specific. 2) I've asked for the piece of code in the linked document, that controls the granularity of the plot, it looks like a fairly simple task for someone experienced in visualization.
3) I have not asked for library_but an open source application. There are several instances of the same all over SO with hundreds of upvotes- https://stackoverflow.com/questions/317944/tools-to-search-for-strings-inside-files-without-indexing/19795152#19795152
Finally, I posted the link here because I have been asking about this problem in this chat room for a week. Some people had taken an interest, so I was hoping they'd have a look.
You may notice that the question with hundreds of upvotes that you just linked is closed as off-topic
01:58
Another example: here's a case when we should use str.partition() rather than `str.split(), if we want to be guaranteed n return values, under all cases: How do I reliably split a string in Python, when it may not contain the pattern, or all n elements?
@pyeR_biz pyeR_biz That linked question is a good question for software engineering, but offtopic on SO (asking for a recommendation of an open source application to search a codebase for X). Which SE network site is it on-topic?
Over on SE.SE questions on 'search codebase' We should migrate this question so it can be reopened!
@smci After looking it up, it's probably good on Software Engineering. I blabbered because in my post, the software request occupied the last spot, and may be 3% of post; and that's the only spot where the attention went to. Is it appropriate to move my post over to SE too? Because of one line. It's okay, I just didn't think this post would get SO flags.
 
2 hours later…
04:11
if I want to check whether elements of a numpy array are contained in a given set, how can I do that?
e.g. seen = set([1,2,3,4]) and arr = np.array([4,5,6]). something like any(i in seen for i in arr) would do what I want, but is this taking full advantage of the O(1) lookup of sets? what's the most efficient way to do this?
probably something like set.intersection or .issuperset. Might be a better way with numpy but I'm not sure
that requires arr to be a set too?
 
1 hour later…
05:20
probably (I haven't used that API recently, so it's not fresh in my mind)
:'(
@WayneWerner why aren't you doing advent of code
or are you
wim
wim
maybe drinking half bottle of rosé waiting for midnight is not good idea
05:39
Regarding Day 5 view spoiler
Regarding day 5, I wrote a lame solution, ran it, "it's never going to finish is it", rewrote, finished and ran my new code before it finished running
not fast enough to get on top 100 so I shouldn't have wasted my time with that idea but oof
wim
wim
ooh the hat turned red
I feel pretty good about it, I just wish I was faster. github.com/pirsquared/Advent-of-Code/blob/master/2018/…
wim
wim
it's really hard to catch up if you miss a day
you go down like 10 points
the only way to compete is to not have a social life for december!
05:46
advent of rat race
wim
wim
it's also the month of work holiday parties ... :D
I think that was a solid question. Not too difficult but you had to think. If you already knew how to handle that sort of thing, then you have a clear advantage.
@AnttiHaapala @WayneWerner is on the leaderboard but you are not.
Yay! @Code-Apprentice just finished the second half (-:
@piRSquared on which leaderboard
I am on 4 leaderboards
119932-f5c26ae6
05:56
well I am on there now :d
Now 5 (-:
good night all
good night :p
@piRSquared nice!
@wim my solution if you are interested
@Unihedron I had the same problem. My first approach was way too slow.
@piRSquared ooo...swapcase()
@user3483203 done
@piRSquared antti is on the Marcus Andrew board but not on the wim glenn one
@piRSquared view spoiler
@piRSquared I really like your solutions today. Very slick
06:54
Hey, I need someone's help today.
Feeling stuck and not sure how to build what I have in mind.
I'll DM you. My questions are many.
shoot ,here you will find a solution
ok, how do I store a list in memory in a jupyter note
I want to build a rough database with only python. Just to see what it'll be like.
Any ideas?
Um, what does "store in memory" mean? Every variable you create is stored in your computer's memory...
As in, somewhere where it will be there even in next execution of code.
(ie, a long-living datastore or database)
ah. You want to store your data in a file.
07:07
Yes. Thank you. Those were the words I was looking for.
Will normal file handling work in colab?
 
1 hour later…
08:11
Do we have a canonical for pandas merging? Cases to be covered - left, right, inner, outer, cross product, asof variants, faster alternatives, merge on index, etc.
 
2 hours later…
09:55
pydata may have it covered somewhere, @coldspeed
@MisterGeeky I'm aware of that link. I was asking if there was a merge equivalent of this, and this
10:11
most likely. If not, just code your own.
checking inside the package using dir(panda) may not be much useful
yeah, that was my intention by asking...?
10:49
panda
^ done
and...closed
Hi. Does anyone know how to accomplish the following? I have a multiprocessing Pool code that retrieves stuff from the db. All works fine. However, when I run my Flask application, same code fails AttributeError: '_MainThread' object has not attribute '_state'. How do you achieve multiprocessing in Flask?
fixed it with upping eventlet to 0.24.1, but now it just hangs when instantiating the Pool
12:11
ThreadPool wroks, but gives the Queue empty error (but it ignores it for some reason)
 
1 hour later…
13:24
how do you interpret wall time in %%time output in jupyter notebook? My CPU time is a mere 1 second, but wall time is 12 seconds.
14:24
@Code-Apprentice thank you (-:
@coldspeed I've been thinking of doing that for sometime but haven't found the time.
Sam
Sam
15:11
Hi all, I'm using Seaborn to create a distplot() object. I specify a fit parameter to the function, and have successfully used scipy's stats module: stats.norm I believe.. But any idea how to specify a gamma fit? I've tried stats.gamma.fit() but the fit parameter of distplot does not take a tuple?
15:22
man. I dorked up day 5 -_-
you post your solution yet?
@AnttiHaapala I think I'm on 3 lol
@MisterGeeky Sure, why not? The simplest one is just a flat text file, or csv file
@wim Or be comfortable with the fact that you're doing better than everyone on earth who's not on the leaderboard at all
hey, there is a txt file on local location, when i type the url for that on chrome it downloads the file but in IE it opens the file, how can i make it auto download.. (i have to use IE :( ), thanks
what's the URI?
or, an example URI
@WayneWerner something like \\xyz.domain.com\root\repo\2017\18\1027586.txt
15:32
Interesting. That looks like a UNC(?) path to me and not a URI which would look more like file:////xyz.domain.com/root/repo/2018/18/1027586.txt
(I think that's the right number of slashes for referring to a network drive(?))
Yup thats right
So... I don't think that you can force the browser to download the file if you're just linking to it like that.
If you have a server then you can send it as an attachment
otherwise the browser will just handle it however it's configured to handle it
but chrome is able to do that.. ?
chrome's configured to download it instead of show it
can i configure IE then ?
15:33
TBH I'm kind of surprised because usually chrome will display .txt files - at least for me
same here
Probably... though I'm not sure where the setting is for that. I'd look for something like "configure IE to always download .txt files instead of displaying them in the browser"
thanks..this helps
np
good luck - browsers are tricky beasts
yes they are
16:14
I'm using AoC as an excuse to finally learn numpy/pandas. Is the best way to get started whatever guides are on their respective sites?
probably? I've been taking the stats courses at khan academy for the same reason lol
Yeah, I've been wanting to get on that too. Never learned stats in school. And I want to learn 3 spoken languages and 2 instruments at the same time... never enough hours in the day. Sigh.
Difficult to specify a "best" way. Both are quite expansive. I'd definitely dive into a task and see where that takes you. Hit up the most highly voted question/answers are on SO to see what other people use it for.
Pandas has a 10 minutes to pandas that is reasonable
my experience so far with Pandas is that some of it is like, "Oh, okay, that makes sense!"
and then you're like, "I just want to do this one simple thiiiiiiiiiing!"
So just be prepared for that
Sometimes what you think will be amazingly easy just is a lot of really weird incantations
Look, as long as they're actually called incantations, that's fine. I don't want to have to change out of my wizard outfit just to use this library.
16:20
I use Pandas for Day 4 because that's where my brain went. I thought better of it afterwards and wrote a different answer.
For day 3 I was trying to figure out if I could use it as an excuse to finally tinker with rust's relatively new SIMD support but I think I want to stick with python til the end for now.
wim
wim
16:38
does this guy deserve a snarky or sarcastic reply? "your wish is my command", perhaps?
"Absolutely! I'm just waiting for the PayPal payment to come through. Let me know when you've sent it."
lol
"I'm accepting pull requests" is a good one
wim
wim
@piRSquared 😆 good
Voting on "successor to BDFL" thing for Python is this weekend. Options are in PEP 8010-8016 if you're interested to read about it.
17:41
Have csv's with 160 channels, 2M rows and. 80 such csv's with same structure. Reading in 20 channels, performing a row wise computation using 7-8 channels only and want to write the new (computed columns + 20 read in columns) data to a SQL db. With file name as table name.
hdfstore numbers are way faster though
17:59
cbg all
for my own reference:
for coord in rect_coord_list:
    if coord not in no_overlap_coords:
        return False
    return True
is not the same as:
for coord in rect_coord_list:
    if coord not in no_overlap_coords:
        return False
return True
...took me about 2 hours to figure that one out :/
Sounds like one of the rare cases where for-else would have helped
or all(coord in no_overlap_coords for coord in rec_coord_list)
@toonarmycaptain ouch. I did that last night. Jupyter or PyCharm (can't remember which) "smart" indented my code when pasting. It did exactly what you showed. Drove me crazy for a bit but fortunately not for two hours.
18:10
I've always had bad luck with smart indenting / auto-placing closing brackets/quotes. Things just keep getting it wrong and I wish they'd just let me do it. I feel like the best compromise is just having return keep the current indentation level and nothing more.
that's what my editor does
you wouldn't want automatic indents after a if ...: or while ...: or try: or something similar? Or automatic unindents after break or return or continue?
no, actually, it adds a level after colon-terminated blocks as well
@piRSquared I'd love to blame pycharm, but I wouldn't expect it to return my cursor an indentation further than the current indentation (which is where it placed that last line, following hitting return after that inner if statement. Any other behaviour would probably cause me just as many problems, so this is on me.
and it does unindent occasionally, but that's risky if you want to get rid of more than one level of indentation
18:23
At least in Spyder, if you copy/paste from a deeper level of indentation, when you paste, the first line is at the correct level and everything else retains the original indentation. I can't see any reason why you wouldn't want to maintain the relative indentation of the whole copied block
I don't know if that silliness is standard across editors, though
18:42
I've had an except: clause end with an if-then-else but the else got copy-pasted at the level of the except:. So it transformed from code that ran once in a while in the exception handler into code that would always run when the try block succeeded. Just 4 little spaces...
Hi everyone, would it be ok to promote my question here since it is not getting answered on SO?
@SAKURA Read the room rules sopython.com/chatroom and see what you think
you may have to give it more than three hours
19:02
@SAKURA I'm on my phone but is there not an xlwings tag? That runtime sounds ridiculous so I assume it gives some on-screen animation of the updates?
please discuss it in comments on the question
Ok. I was just gonna leave it at that but I'll add to the question
@piRSquared ooh, it's settled then. I seem to have found myself with a bit of spare time so I think I can give it a shot.
@coldspeed let me know when you’ve done it 🙂
wim
wim
20:08
> ... BDFL model of Python governance, to be henceforth called in this PEP the Gracious Umpire Influencing Decisions Officer
heheh!
20:21
hello
I've been trying for a few hours to get a image from media folder on django
<img src="{{ MEDIA_URL }}image.png">
but I only get The current path, /media/image.png, didn't match any of these.
you know how to fix it?
@OanaAndone I'm a Flask user, not a django user, but relying on the template renderer to concatenate strings doesn't look correct at all
after run results <img src="media/image.png">
Hmmm, but the docs don't convince me that you're wrong in your approach. I'll have a quick search; jinja2 is much more elegant than that, but I find it difficult to believe that this is the django approach that they improved on
yes, but even if I access image directly in the browser 127.0.0.1:8000/media/image.png , not working
Where is your media folder? I have a feeling my understanding isn't as portable as I thought over to django
20:36
is in /djangoproject/media
I also use virtualenv
but static folder works with css js
I'm gonna have to back out. Template rendering is too different between the two, sorry. Me throwing guesses won't be helpful.
I understand you, and I appreciate it
n8_
n8_
20:59
@coldspeed, mind if I ask another question related to my post you answered?
@n8_ sure
n8_
n8_
So what if I want to use your logic to compare to columns? Like if column a = 'Alive' and column b > 0, then write to csv.
Something like this (but this is obviously wrong syntactically) ` c = df.columns[df.columns('VitalStatus')][0]
d = df.columns[df.columns('AgeAtDeath')][0]
if df[df[c] = 'Alive'] and df[df[d] > 0]:
to_excel('invalid.xlsx', 'VitalStatus')`
opps, pasted wrong
I can also make another post if you prefer
Don't want to rob you of rep
@n8_ You can't rob someone of rep for not answering follow-on questions that's you've thought of since the question was answered.
n8_
n8_
I just meant I don't mind posting so he can get rep for answering a different question
even if it's related
21:18
Ok, but that's also a different issue. In that case, your question might be closed as a dupe. The point is to keep a repository of solutions to generic problems useful to others, not just an approach targeted at your specific issue. If you're genuinely unable to solve the follow-on issue, maybe it merits a new question, but a narrative through your issue, over multiple questions, is unlikely to be helpful to others
n8_
n8_
Gotcha
In any case, you might try something along the lines of df = df[(df[c] == 'Alive') & (df[d] > 0)] and then check if the df is empty or not (I may well have issues in syntax, it's to illustrate)
It's surprisingly difficult to balance parentheses with giant cracks up my phone screen :P
not that surprising :P
I thought that immediately after typing it, but then an edit still requires me to go back to Google and reload chat to manage my comment. At least the smashed button that used to frantically highlight random chat comments seems to have calmed down :P
21:34
hehe
incidentally, I'm buying a new phone. Already ordered, just need to pick it up
sounds like its time to get a new phone
what you get, Andras?
Android, I pray
yup, a samsung
Phew. We couldn't be internet acquaintances otherwise :P
I'm allergic to apple and I hate microsoft so there's not much left
blackberries are weird
21:38
@Code-Apprentice I think my phone is still in the realm of a superficial fix. There's a bit of hardware showing, though. It wasn't a simple drop, I tripped and went down with it, smashing it into the floor in my hand :/
Don't know if it would have saved your phone from that kind of smash, but I can recommend a spigen case
I drop my phone an unreasonable amount of times, and in the ~3 years I've ab used it there is still no crack in it
Could it also save me the humiliation of it happening in a pothole in the middle of the busiest street in Manchester? We're talking a minimum of 300 people that watched me go down.
oof
only cognitive denial strategies can help there
"It was probably just a dream"
If you have no cracked phone to prove the opposite, you might believe it one day!
So in the end I'd say, yes, it can save you :p
Karma is so brutal. I'm the guy that hasn't gone down for 10 years and laughs at everyone falling on their backside while hiking. My biggest nemesis is apparently a tarmacked road
My mate has the line "how embarrassing FOR ME" which basically steals anyone's thunder over such a situation, but I was scrambling about. Not. My. Finest. Day.
21:48
meh, ignore what other people think
I wouldn't be recounting it here to non-witnesses if it bothered me :)
n8_
n8_
@roganjosh, your solution worked for me. Thanks
I was bashing my head against the screen!
Welcome :)
@roganjosh ouch
22:08
This is going to sound really dumb, but where does the sql database made from df.to_sql go? it's not in my working directory
if I had to guess, I'd say into the 2nd argument
Create an in-memory SQLite database. (from to_sql doctstring). So in the examples the db is being created in memory. So I have to initiate a SQL db on my hard disk first. And then append data. I haven't done that before.
22:28
@pyeR_biz I'm not sure that makes sense. I also haven't done it, but it sounds like a convenience to allow you to use SQL syntax. I would imagine the SQL database disappears at the end of your program
I just need to convert a list of pandas to a sql database, because the another analyst needs it in sql DB form. I have no use for running sql queries myself
:memory:, to my understanding, is completely useless unless you want to demo something on Stack Overflow
I guess I am missing some very basic sql db work. Like engine / connection / cursor etc; I though df.to_dql will just a .db file which someone can access
completely subjective: I wouldn't try manage an sqlite database via pandas
@roganjosh I have to, it's a one time thing. I just did some subject matter related analytics on the data; and returning the new columns to the db guy.
22:36
I don't buy that you have to. Use the standard sqlite3 library to make the actual database. Pandas can be really unpredictable with its convenience methods. There's no reason, that I can see, to rely solely on pandas here
Presumably your DF has the correct orientation and data that you want to write to the db. Just use .values to grab the data and then use executemany from the sqlite3 library. Then, at least, you know what's happening
I'm totally confused. I'm just going to write the calculated parameters to csv and let him do the import to DB
I'm totally confused. You said "I just need to convert a list of pandas to a sql database". Now it's a CSV
can we chat in a private room
There's no reason for that. I just think you need to be clearer in your mind of what you're trying to do.
22:51
Thanks for listening. Ok, so I was given some data (80 csv's, 160 channels, 2M rows) . I applied an engineering logic to the channels, and calculated a new column 'ouput'. My pandas DF is now simply an index-output for each .csv, so 80 Dataframes with one variable and index - identified by filename; I can write these pandas to a sqlDB or csv so the guy controlling the database can import my results. I don't have direct access to the central DB, which is why I was given csv files as input.
So dump the output to a CSV and let them process it?
@roganjosh Yes I guess. will writing to and reading from SQL be faster though?
It sounds to me that you've been given some obscure task so just throw your output back. Forget about SQL.
@roganjosh Ok
Thank You
<hoping I've not just put you in hot water>.... :)
If it mattered between sqlite or CSV, then the DB guy would clarify. If it does matter, well then it's up to them to tell you it's the wrong format, and then you at least have clarification. This is not a programming issue, it's... people.
23:01
No I was the one pushing for sql, because there are applications for that ahead as well. I would have preferred HDF5; but they need to use the data in PowerBI, which doesn't support HDF5 yet. I'm processing the data from subject matter point of view, so I will have more outputs to throw downstream. Baaaahh... might try sql again
Hello I have a for loop like this:
for x in cars:
car = Car()
...
Every car is the same
Is it posible to crate multiple class instances on the same loop?
It is entirely possible. You have some bug you haven't shown us. Maybe mutable default arguments, maybe class variables instead of instance variables, maybe one loop that creates cars and a second loop that prints the last car over and over... we can't tell.
@MarcosAguayo the answer is... I think so... but I don't know what you are doing. You'll have to explain a bit more.
@pyeR_biz well in that case, join my club of being frustrated with logic of people in charge. But there are some battles better lost. Again, totally opinion, but I'd drop this battle if it's not critical and fight the battles on things important; if a dollard wants avoidable work on their plate, so be it.
@roganjosh going ahead with csv. thanks
23:10
@pyeR_biz as I've ranted in here before, I dutifully maintain a directory of tens of thousands of CSVs of data because our IT dept refuses to allow me to help them query my database <shrug>

« first day (2972 days earlier)      last day (2201 days later) »