« first day (1853 days earlier)      last day (3111 days later) » 

11:29 AM
0
Q: Converting text columns to libsvm format using feature hasher from scikit learn

stackitThis answer links to a code which only works for numeric data , but I have CSV file for machine learning which has mostly text data and most columns have a large cardinality , eg: a column with name of a person. Ideally would like to use the scikit learn's feature hasher or a vectorizer to gener...

How can this be achieved in python using featurehasher
of scikitlearn
@AbhimanyuAryan Nice thought
@Lam perhaps you can answer above
@ᐅJohannesSchaub-litbᐊ
can anyone answer the above question?
 
@stackit Please do not post recently posted question into chat. Stack Overflow works well without you advertising it in the chat room. Someone who knows an answer will eventually find it. Just give it a bit more time.
 
@poke Thanks
 
test1
 
11:55 AM
!
Why was I not aware of the struct module before now!?
 
Nik
Hey, I have a little problem.
2
Q: Find the Length of a Song with Pygame

JRJurmanI'm building an Radio Automation Program, but I can't figure out how to have a timer countdown the number of seconds left in the song. I'm currently using Pygame and don't really want to load another toolkit just for this. So far I can make a timer count up using this: import pygame #setup musi...

Do I really have to load the entire thing onto memory!? I mean, isn't that bad?
 
Nik
@IntrepidBrit Woah, that looks ugly. Sure that may work on wav, but I was hoping to also play .mp3, .midi and .ogg too. What about for them?
 
I don't know. But the above is the result of me quickly googling the problem
 
Pygame is the best option I've found for audio in Python. It just doesn't really seem to be a strength of the language.
 
Nik
12:05 PM
With a bit of research this topic is really getting icky, I wish there were some way to make the current drive into a cd object or something. But cdrom is really undocumented for newbies.
Another idea I got was to use eyeD3 to get the tracklength of .mp3 files.
@TigerhawkT3 I see that too. I think in the end, my program is going to be very bloated just to do basic things.
 
What about Mutagen?
 
Nik
12:26 PM
@IntrepidBrit Interesting. Will consider. Thanks.
 
1:12 PM
@PeterVaro I'll take a look at it, thanks.
In other movie chat, I watched Citizenfour last night. The ethical implications are complex, but one thing is clear: Snowden should get that mole looked at.
 
Cbg :)
 
cabbage
 
@Kevin I gave it 9/10 when I watched it (half a year ago or something)
it is definitely worth watching!
btw @Kevin what "other movie chat"?
 
1:27 PM
@paul23 Take a look at mpmath "a free (BSD licensed) Python library for real and complex floating-point arithmetic with arbitrary precision." Not only will mpmath give you a sine function with as much precision as you like, it also has good root-finding and calculus functions, plus various esoteric functions.
 
By that I mean "in other news regarding the subject I was just talking about in my previous message", rather than "in the other chat room whose subject is movies"
 
aaaaaaaahhh, ic
I hoped there is a decent chat room about movies worth watching :)
but I guess we have to continue to talk about them here :P
 
@PeterVaro It’s not like this room is active today anyway, so please continue
 
2:00 PM
@Kevin I keep meaning to watch that. Would you recommend it?
 
If you have a prior interest in the scandal or of political intrigue in general, sure
 
@PM2Ring Thanks for the advice lol
 
Mama Kevinson had neither so she spent a lot of the viewing on her phone. So it goes.
 
Need to read a bit about that before I change thouhg - I depend already heavily on numpy
And I'm well versed with that
 
@Kevin I've been following the Snowden leaks since they started, so I'll definitely have to watch it. Thanks.
Did you ever see the interview he did with John Oliver on Last Week Tonight?
 
2:11 PM
Can't say I have
 
@paul23 That can be a slight problem with mpmath, however you can often change stuff to use mpmath with only minimal changes to your code. Eg, you can often get away with just changing one value in an expression into a mpmath number, since when that value is combined with normal Python numbers those numbers will be promoted to mpmath numbers. OTOH, it's not a good idea to use that automatic promotion on Python floats, or you inherit the crappy float approximation.
 
I don't use numpy, but mpath and numpy can work together, eg stackoverflow.com/questions/13743785/how-to-mpf-an-array
 
morning friends
I got new coffee -- Valhalla Java
 
However, for doing orbit calculations you probably don't need the high precision that mpmath makes available, after all, people were doing that stuff by hand for centuries, and you can bet they weren't using more than 15 significant figures. :)
But I guess mpmath could be rather handy for doing stuff like solving Kepler's equation, although I've always found Newton's method to be adequate. And if you're just doing pure elliptical orbits that ignore other bodies then your orbits are only going to be approximate anyway.
 
2:29 PM
Possibly interesting to nobody but me: the leaves of a fractal tree with parent-to-child-branch-length ratio 2/3 and with angle 135, has a striking resemblance to the Levy C curve.
 
pretty
 
@PM2Ring Well actually there's a difference between what's done in 1600 and what we (I) do now. In 1600 orbit caclulations were based on "magical points" where it can be solved algebraically. However this can't account for everything. It's a 2 body approx - except in the lagrange points, which are special points allowing you to solve a 3 body problem. you can't solve kepler's equation in just any point.
The 3 body problem is done in modern day either by simulation of the differential equations. - Which has the problem of being unstable and hence any error grows exponential with the time (and a flat error like the floating point also grows with smaller stepsize). or by adding the lagrange polynomials (J1 accounts for flattening of earth, J1,1 for the fact there's more mass to the east of greenwich than the west, J2 accounts for extra mass around 45 degrees latittude etc etc).
But these are highly unsolvable other than by numerical methods. (Though J1 is used to move a satellite to it's correct position and together with j1,1 it is used to account for sun synchronous orbits).
 
@paul23 Speaking of 3-body problems, how do you like this orbit? It was discovered by Cristopher Moore, 22 years ago. For more details (and more fun orbits) see This Week's Finds in Mathematical Physics (Week 181) by John Baez.
 
Whoa, spoiler alert! The Three Body Problem is still on my to read list.
 
Anyways these added forces are very small compared to the main force, J1 is a million times as small as j0 (main body gravity), J1.1 is about 5000 times as small as j1. And j2 another 1000 times as small as j1.1.
Haven't had to use any more accuracy than j2 though.
 
2:36 PM
cabbage!
 
Is this one of those "looks cool but is fundamentally unstable and will collapse with the slightest perturbation" things?
 
It's however the weird thing about python: it simultanously good and not good for scientists.
Any 3 body is kevin
 
If I write a scifi novel with this orbit as a premise, what percentage of my readership will write me letters starting with "Actually..."?
 
Well until the third body is so far away from the other two, that the other two are approximated by a single body
 
user559633
@Kevin It's a very smart group, so they'd do the "I think you may have made an error," which is the polite version of "well, actually"
 
2:38 PM
Well kevin: there are the earth trojans that follow a horshoe orbit due to the highly unstable lagrange points (L2,3
 
@Kevin IIRC, it's reasonably stable as long as the 3 masses are identical. Here's a 4-body one:
 
user559633
Now show me two of them in which two of the bodies are centaurs!!
 
Those orbits are in horesshoe due to the earth & sun.
 
Assuming a perfectly spherical centaur in a vacuum...
 
It's unstable, so asteroids are only for like 1 million years in such an orbit
 
2:41 PM
Neat. I hope America's legislators are prepared to fund missions to explode these asteroids.
 
After that pertubations of "other" bodies, or even momentum changes due to body rotation locking/non perfect spheres will throw it away.
 
user559633
Wait, wouldn't the asteroid get pulled into the space between the earth and sun (A->E)? I'm calling shenanigans on reality
 
@Kevin On Pythagoras Tree You can see looking at the block illustration how each step forms the Levy Curve.
 
@tristan Talking about the horseshoe? - it's not an asteroid starting from rest remember.
You have to account for accelerations
 
user559633
Am I to understand the cyan color as its potential path?
 
2:43 PM
yup
upload.wikimedia.org/wikipedia/en/d/d5/… <- this is an actual measured one
 
user559633
Oh, it just made sense. This is incredible
 
Earth has quite a few trojans...
Since earth is the heaviest of the inner planets the pertubations due to Venus and mars are small. Jupiter is after Earth & the sun the largest force.
An Earth trojan is an asteroid that orbits the Sun in the vicinity of the Earth–Sun Lagrangian points L4 (leading 60°) and L5 (trailing 60°), which means they have an orbit similar to Earth's. Only one Earth trojan has so far been discovered. The name trojan was first used in 1906 for the Jupiter trojans, the asteroids that were observed near the Lagrangian points of Jupiter's orbit. == MembersEdit == Current L4 (leading) 2010 TK7: A 300-meter-diameter asteroid, discovered using the Wide-field Infrared Survey Explorer (WISE) satellite. It is the only confirmed Earth trojan. L5 (trailing) No known...
 
I guess the angle's a little different though.
 
Naming for trojans is quite fun: the Trojans leading a planet are named after greek heroes, the ones lagging behind the planet after the Trojan heroes
 
@QuestionC Makes sense. looks like the length ratio needs to be 1/sqrt(2) to get a "true" pytagoras tree. 2/3rds is about 10% smaller than that, so I had a reasonable approximation.
 
3:01 PM
Guys :| I've been doing everything so wrong
 
We know, we've been telling you for years, but the Human / Crow language barrier is difficult to overcome.
 
Perhaps you can express it in caws?
 
user559633
Inappropes.
 
caw Caw cAw cAW, flap, CaW, strut for 0.3 meters
 
I was going to make a more inappropriate response
 
3:03 PM
 
user559633
HOW DARE YOU
 
whoops, wrong inflection
 
user559633
Common misunderstanding
 
I... I had no idea you felt that way Kevin
 
3:04 PM
@paul23 That's the traditional theory, but in modern times other stable solutions have been found. Here is a short paper (with diagrams) that investigates the stability of that figure-8 orbit. As I thought, it's reasonably stable to position perturbations, but not so stable to mass perturbations.
 
user559633
Haha, oh, you meant "Caw Caw cAw cAW, flap, CaW."
 
wat
 
Here's my number, caw me maybe
7
 
user559633
I thought you were criticizing my grubbing and I was going to flap wings at you
 
@Kevin wow.
 
user559633
3:05 PM
I aint too proud to star that
 
I’m neither, but I did anyway.
 
user559633
Cawly Rae Jepsen
 
@PM2Ring Still the fun in python here though. To calculate these things you wish to have good control over accuracy etc.
But on the other hand - the accessibility of python and ease of use make it well suited for scientific computing.
 
user559633
Let's carrion from these crow jokes.
 
:-|
 
3:07 PM
Caw about no? :(
 
But it's soo slow. And when I talk about algorithm optimization (Big-O and amortized average speed) & choosing the correct method the answer is always: just use the library and test it.
 
I can't stop raven about these puns.
 
user559633
jayyyy lmao
 
user559633
I can't believe that passeri formes regular type of humor.
 
user559633
I love that there's such a thing as a "True Crow" because now every time I make bird jokes I'm going to make "No True Crow" fallacies
 
3:10 PM
These puns are murdering me.
4
 
user559633
Amazing
 
@MorganThrapp I guess we can afford to sacrifice one or two.
 
Is that a pun by way of crow -> rook -> chess -> sacrifice, or am I over-pattern-matching again?
 
@Kevin Speaking of fractal trees, check out this short Python script that uses cairo to do a fractal tree - it's about 2/3 the way down that page. FWIW, only a tiny change needs to be made to get clean SVG output: just change surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width,height) to surf = cairo.SVGSurface(svgname, width, height) and drop the write_to_png call (the surface will save itself automatically).
 
@Kevin Yes, exactly. You’re so smart.
(sorry >_<)
 
3:12 PM
[success_kid.png]. Saw what was done there.
 
@Kevin s/saw/caw/g ?
 
I dare not venture to guess, after what I've already said.
 
Hmm so I now understand that python functions are "objects". And default arguments are made members. Now I'm wondering about the consequence. Does this mean that at any time I can "get" the default value for a function? - Or does it mean that after the function call ended I can get the last input values?
 
@Kevin That's disgusting. Linking to cawnvicts like that?
 
:-D
 
3:19 PM
@Kevin Works for me. Also, a murder of crows.
 
I can't find an example of what I want to do in D3, I think this might be the first time ever ;_;
 
@paul23 Yes, you can get the default args, but (AFAIK) you can't get the last args passed to a function that's already returned.
>>> def f(a=37):
...   return a
...
>>> f.func_code.co_varnames, f.func_defaults
(('a',), (37,))
 
Wait python is from google?
(reading starred lines)
 
3:35 PM
The only reason I can think that was starred is because we were all laughing at how wrong that message is.
 
@paul23 no, we clarified that back then.
7 hours ago, by Abhimanyu Aryan
really? @metatoaster good to now. I will star it now. I think its funny
 
@davidism Well it's now just too out of place to even.
 
DSM
3:47 PM
Thursday morning cabbage for all.
 
cabbage
 
DSM
Frustrating client just tried to slip in a 40% increase in the number of modelled diseases and a completely new target population never before discussed in an assumptions document, the only point of which was to get them to sign off on our numbers. This week has just gotten more complicated. :-/
Where's a good itertools question to cheer me up?
 
@paul23 Usually, the way to get speed in Python is to use a library that implements the slow stuff in C. But you may not get a library that does exactly what you want. Eg, say you want to simulate some system from its differential equation(s).
The usual recommendation is to use some library to do Runge-Kutta integration, but that's not good for celestial mechanics because it doesn't conserve energy, so you end up using a ridiculously tiny time step. OTOH, there's Leapfrog integration, which has much better performance, but it's not as well-known, so good luck finding a library for it.
 
DSM
@PM2Ring: ooh, I used to write symplectic integrators. My former supervisor was one of the crew who first devised a good way to handle close encounters symplectically. :-)
 
Uh the prof & everyone I know actual implement the numerical calculations in python, "cause libraries never documentate well enough for scientific communities"
Proof for convergence and consistency
 
3:56 PM
@DSM Nice! Leapfrog's symplectic, but the Hamiltonian it conserves isn't exactly equal to the actual Hamiltonian of the system. :) But still, that's enough to keep the sim stable, and with a small enough time step, close to reality. And the synchronised version of Leapfrog (about 1/2 way down the WIki page) is quite easu to code.
 
On this episode of Comments in our Code: "INITIALIZATION CODE IS VACUOUS ".
 
@paul23 But they trust the Numpy library and the math module functions... FWIW, the mpmath source code is all available, and well-written. So if you really want to study it to make sure it's correct, you can. Sure, that's not the same as having full descriptions of the algorithms in the user docs, complete with proofs, but hey, what do you expect? You rarely get that sort of thing from libraries you pay for.
 
DSM
@PM2Ring: yeah, working out the actual surrogate Hamiltonian can be a bit of a nuisance because the naive expansion doesn't converge, and so adding more terms makes the match worse after a while. There's some very interesting geometric stuff going on there.
 
fixed the issue.. the matrix was one dimensional while I thought I had formed it as a 2Dimensional matrix.. Thanks everyone who tried helping me — javaaddict 48 secs ago
 
@Ffisegydd new book recommendation: Promise of Blood by Brian McClellan, who was a student of Sanderson's
 
4:14 PM
@davidism Ta love. Will look it up tonight, need something new to read.
My friend is working through the Abercrombie books.
 
@DSM: You might enjoy the writings of Australian scifi author Greg Egan: "I was born in Perth in 1961. I have a BSc in Mathematics. I’ve worked as a computer programmer, mostly in jobs supporting medical research of one kind or another. But I’ve been writing full-time now since 1992." Many of Greg's short stories have a medical theme, eg Yeyuka.
He still does some programming for fun, and FWIW, he's a friend of John Baez. I've been reading (or re-reading) most of his work for the last month or so. And although a lot of his stories can be a little too dark for my taste, I've been enjoying it immensely.
 
Oh D3 you fickle mistress...
 
4:36 PM
Book chat. Someone recommended to me The Northern Caves, which is available online. I mostly liked the author's previous work Floornight, but I thought the ending was a bit weak. I'm 60% of the way though TNC and it's been methodically foreshadowing some momentous event, so I hope he sticks the landing.
 
DSM
Oct 13 at 18:42, by DSM
These days, if the threat is scarier than "The villagers were worried the rain would cause problems for the Easter egg hunt", I'm out.
 
The story is about a group of ~6 children's book enthusiasts trying to decipher the seemingly demented final work of their favorite author.
Not sure precisely how high the stakes could be raised. So far it's all been realistic fiction, but considering the subject material, it could swerve cthonic at any moment
"This jumble of indecipherable symbols in chapter 17 is actually a summoning spell for Yaldabaoth" or suchlike.
 
DSM
I read that as "cythonic", which I guess makes sense in this room. :-)
 
@DSM I can relate to that. :) Greg does write some horror, although most of his scifi work isn't horror, per se. The story I linked earlier has some sad stuff, but it's overall tone is positive, IMHO. But don't expect Disney endings from him. I wish he'd write more optimistic / uplifting stuff. OTOH even when he's telling a bleak tales he manages to include some humour.
 
4:54 PM
A couple of days ago I finished reading Greg's Incandescence, which features an alien world orbiting a neutron star, where a pre-industrial civilisation discovers General Relativity. It's great to read books that feature hard science without screwing it up. :)
Greg's site has a section called Foundations which has some great articles on relativity and QM. They aren't exactly suited to a general audience, but anyone with high school algebra & calculus should be able to follow them.
 
DSM
5:16 PM
This coach/train question makes me inexplicably happy as well..
 
5:35 PM
:) It reminds me of a fake mondegreen I coined many years ago while listening to Hendrix's Hear My Train A Comin'Hear My Trainer Comin'
 
5:45 PM
@PM2Ring In frozen Anna didn't fall in love with Kristoff. Not the perfect ending!
 
6:15 PM
cabbage
 
6:40 PM
Ooo, restaurant downstairs today has ghost pepper tacos
 
Mmm, sounds painful delcious.
 
I've done the ghost pepper wing challenge before. You have one thing to remember: what goes in, must come out.
 
My diet consist mostly of spicy foods and coffee. My stomach acid is caustic
 
Anyone else just have the main site go down for them?
 
Nope
 
6:45 PM
Huh. I'm getting timeout issues, but I can connect to other sites fine.
Wait, I may have spoken too soon. I can ping other ips, but my DNS server seems to be having issues.
This is really weird. My DNS won't resolve SO, but it's fine with other sites.
 
Time to find out why your sys admin is trolling you
 
Bah, who needs urls when you can just go directly to 104.16.37.249 -- oh, "Direct IP access not allowed". Stop trampling my rights, SO!
 
I'm the closest thing we have to a sys admin. :P It's working now, so who knows.
Also, I'm 1 rep away from close votes. :/
 
Don't be frightened by your sudden metamorphosis. They don't mention that in the FAQ for some reason.
 
Yay, I can close things. Now I have to work on being able to approve tag-wiki edits, because that's a useful privilege.
 
6:56 PM
This is a hindrance. I'm listening to music through my phone's web browser, but the playlist won't advance from one song to another unless the screen is active.
 
https://stackoverflow.com/questions/33678102/tcp-ip-hijacking-launga‌​ge-and-os
 
And apparently the phone doesn't have a "never go to sleep ever" setting. Best I can get is ten minutes.
 
Download the app then Kevin
 
No, this is my life now.
 
A man who sticks to his principles.
 
7:03 PM
Ok, I downloaded it. When this song ends in 2:35, I'll know whether it auto-advances.
Update: it does. First world problem resolved.
 
You had me worried for a minute there.
 
Woo free beer.
 
"free as in beer" beer, or "free as in speech" beer?
 
Free as in beer beer.
 
I'll take 10, how much?
 
7:14 PM
Try my special Libre beer, which has diplomatic immunity. Take it to the movies, feed it to children. Nobody can stop you.
 
It's GNU/Beer.
 
Looks like I'm 11 years late with my joke.
Free Beer, originally known as Vores øl - An open source beer (Danish for: Our Beer), is the first brand of beer with an "open"/"free" brand and recipe. The recipe and trademark elements are published under a Creative Commons license. The beer was created in 2004 by students at the IT University in Copenhagen together with artist collective Superflex, to illustrate how concepts of the FOSS movement might be applied outside the digital world. The "Free Beer" concept illustrates also the connection between the long tradition of freely sharing cooking recipes with the FOSS movement, which tries to...
 
Is there a statute of limitations on being Kevin'd?
 
user559633
Oh. Uh, okay. So basically you have to do the work, but a designer that wants you to share his design around the world. Pretty good microcosm of Linux graphical stuff.
 
user559633
It's not enough just to share; it must be politicized and branded
 
7:26 PM
@Ffisegydd Nope; you can get ninja'd from prehistory if it turns out the Chauvet Cave Paintings already contains your idea.
 
OpenCola is a brand of open-source cola, where the instructions for making it are freely available and modifiable. Anybody can make the drink, and anyone can modify and improve on the recipe. The original version 1.0 was released on 27 January 2001. Current Version is 1.1.3. Although originally intended as a promotional tool to explain free and open source software, the drink took on a life of its own and 150,000 cans were sold. The Toronto-based company Opencola founded by Grad Conn, Cory Doctorow, and John Henson became better known for the drink than the software it was supposed to promote....
Huh, I'll have to try that.
 
user559633
Before anyone gets any big ideas, my cynicism is closed source and I'm very litigious
 
DSM
Szechuan beef for lunch; donut for dessert. Thursday is looking up.
 
Chippy tea.
Battered sausage, chips, and curry sauce.
 
Carrots and vitamin water, in my experiment to see if I can get rid of my paunch without exercising.
 
7:42 PM
Leftover Chinese food, because I'm broke and it was in my fridge.
 
turkey burgers and sweet potatoes
 
user559633
I ate a handgun and washed it down with the blood of my enemies from a human skull cup for lunch.
 
DSM
I added a "you should upgrade to Python 3" comment at the end of an answer which meant I was outgunned by nine seconds. :-/
 
7:55 PM
A worthy defeat.
 
user559633
Did you delete the answer?
 
DSM
But of course!
It was character-for-character the same.
 
user559633
:/ that's a shame
 
You should have deleted the other answer.
 
DSM
:-)
 
8:00 PM
I could just close the question. That'll solve all of this.
 
user559633
Hey, so sorry in advance for this sucky hard-to-answer question, but what suggestions would people have in speeding up web scraping/ETL work? when i'm finding data, i typically copy down the content, use xslt to convert it to xml, then xpath, then use python's build in data structures, before dropping it off into sqlite or nosql. do people have favorite interactive libraries? am i missing out by not using pandas?
 
I haven't used BeautifulSoup, but that sounds like exactly what it's there for.
 
DSM
pandas is great, but not so much for the scraping side of things, because it doesn't handle malformed data well.
(oh no Morgan just mentioned BeautifulSoup to tristan everybody run)
 
hmm the one about imports doesnt seem quite right ..
 
user559633
@MorganThrapp REEEEE
 
8:02 PM
wants to insert ascii art of person running but isn't Tristan
 
re-cbg
 
~*~*~All soup is beautiful~*~*~
 
I know it's not close enough to the metal for you.
 
user559633
I just find xslt to be cleaner/faster to use, etc.
 
user559633
Also, not hosted on github are-you-kidding-me-man
 
user559633
8:05 PM
This is the second time you've suggested it though, so maybe I'm missing out here. I'll revisit my prejudice towards it, thank you.
 
Or maybe the superliminal messaging is working.
 
8:18 PM
cabbage all
 
user559633
hey!
 
@MorganThrapp I hate being close to the metal. Every script I write starts with self = NewProgrammer("AdamSmith") and ends with self.git_commit(__file__).
 
heh...looking at Python videos on interview questions and get Monty Python videos instead
 
@JGreenwell That sounds win/win
 
well except I was going to study & code and now I'm watching Monty Python
 
8:26 PM
@AdamSmith That's still too close to the metal for me. I just yell at my computer until I have a working script on my hard drive.
 
Similarly, I googled "lightbox" today in an attempt to find some nice indoor lighting, and I got javascript library advice instead.
 
My co-workers hate me, but greatness has its sacrifices.
 
How do I check an input for an integer in Python? seems to be falling into the trap of making sure that his program works for correct input, but not making sure that his program fails in the proper way for incorrect input.
... Or else he would not have posted "thanks it worked great :)" in response to the answer that is effectively a no-op
 
@Kevin I agree my answer is the right one ;P
 
I do think Joran's is the most useful answer, although it's answering the Y and not the X
 
8:31 PM
but thats what he needs ;P
 
@JoranBeasley well I mean, the user could try to CTRL+C out of the prompt
 
that's why you do except AnythingButKeyboardInterrupt :-P
 
Or the system could run out of memory.
 
Too bad; we'll go down with the ship.
 
love Morgan Thrapp's comment :D
 
8:32 PM
I'm using a lot of semicolons today.
 
We need more OOPs.
 
DSM
"searching endlessly" apparently means "didn't even both to try 'python dictionary index value for loop' in google" nowadays.
 
OOPier!
 
@JGreenwell Thanks. :)
If it's more OOPy in Python, is it POOPy?
 
I also corrected the other answers in bold at the bottom
 
8:34 PM
actually just "python value for loop" gives a good couple of answers/examples with Google
 
@DSM Maybe he's searching endlessly using completely random dictionary entries.
"I searched for 'snowflake tuttis saddlebag disbursed kerb salliers', but no luck"
3
It could take billions of queries before a relevant result!
 
@AdamSmith i fixed my bare except :P
 
@JoranBeasley I removed my comment.
:P
 
Is there a way to figure out where a song is going to go other than listening to a lot of songs? Like, music has rules right?
 
lol you like my explanation for the OP?
 
8:38 PM
Four words into the title of statsmodels heteroscedasticity breusch pagan test doesn't match, and I thought life was imitating art re: my previous message
 
@Kevin I have no idea how I would google any part of that particular question
 
ooh I haven't poked at one for a long time
I'll look at it on my lunch -- gotta get a report built for CEO in checks watch 15 minutes
 
go go gadget business
 
DSM
In my head I hear the Mission Impossible theme playing.
 
8:45 PM
> The hard part of this problem is going to be talking to the microphone.
People understand that "Talking to hardware" doesn't mean physically talking to it right?
 
user559633
@QuestionC oh..wait. are you sure?
 
9:17 PM
@QuestionC In the case of a microphone, you could leverage a TTS program to make your program talk to it.
 
@QuestionC I think the answer is the same as if you replaced "song" with "story" and "music" with "English"
You can predict roughly what will happen when the cheerleading bus breaks down outside the dilapidated farmhouse
Even if you can't read the first half of a sentence and determine the second half with complete accuracy
 
9:32 PM
I think I'm losing my mind. Why can I not manage to translate this into a list comp?
for b in l:
    p,v=b.split('o')
    s.append(m[p[-1]]*int(p[:-1])*d[v])
This is what I have: s=[m[p[-1]]*int(p[:-1])*d[v]for drink in l for p,v in drink.split('o')].
But it keeps giving me KeyErrors. It seems like it's iterating on the keys.
 
what does l look like?
 
['4Gow', '1Koe', '1Bov', '1Gow', '2Sot']
 
and m?
 
American Ultra => 1.8/10 // it was terrible
 
m={'B':3,'C':25,'G':2,'K':50,'S':.2}
d={'b':1,'e':0,'h':2,'j':0,'r':6,'t':7,'v':7,'w':3}
 
9:38 PM
for p,v in drink.split('o') won't do what you want it to
you're trying to use it kind of like a 'where' clause in haskell/etc.
but it's actually iterating over the contents of the split
 
Really? I thought that's how you did a nested list comp.
 
so your first p,v are going to be 4 and G
instead of 4G and w
it is, but a nested list-comp is a replacement for a double for loop
 
Oh, huh.
 
your original code only has the one
 
Right, duh.
 
9:40 PM
what your listcomp is doing is:
for b in l:
    for p,v in b.split('o'):
 
Ahhh, duh.
 
so b.split('o') gives you ['4G', 'w']
and your first p,v splits the 4G up into two things
which fails from keyerror, but even if it didn't
the next iteration would try to split a w into two things and then fail on the unpack
it's only getting as far as it is because the first split happens to be two characters
 
Yeah, that makes sense. Not sure what I was thinking.
 
Are you golfing again?
 
Yeah.
 
9:43 PM
s=[m[p[-1]]*int(p[:-1])*d[v]for p,v in (b.split('o') for b in l)]
^ that works
 
Beautiful, thanks. :)
 
you can eliminate a couple more spaces around the parens
 
Yeah, I knocked those out.
 
you need the parens?
 
@CSᵠ Yeah.
 
9:56 PM
bit more golfing for ya:
q=dict
m=q(zip('BCGKS',[3,25,2,50,.2]))
d=q(zip('behjrtvw',[1,0,2,0,6,7,7,3]))
i think renaming dict only saves one character but w/e
 
Oh wow. I always forget that you can do that.
Actually, renaming dict costs one byte.
If I knew that there would only be one digit of drink, I could save 3 bytes.
Anyways, I'm heading home. Rbrb all.
 
10:13 PM
@idjaw Hmm I'm thinking linked lists
 
@AdamSmith A couple of us at work worked it out yesterday, so I have the spoilers. If you want to talk solutions, I'll spill. :)
 
I've thought one up, but it's big O is off the charts
I feel like it's solvable in O(n)
should be able to get first and last element by finding which elements appear only as the first or last positions of the tuple
 
I was shocked by this, I saw a solution done in O(n^2) that passed the time test
 
and recurse
 
the last test, tests how "efficient" your code is to ensure it solves it in under a specific time
 
10:23 PM
gotcha
 
10:52 PM
I feel dumb for asking this, but what's the best way to get an item from a set? Any item at all
Python2 if it matters
set.pop is great but I don't want to remove it. I could do foo = set.pop(); set.add(foo) but that seems silly
 
DSM
@AdamSmith: canonical approach is next(iter(someset)).
 
thanks
didn't want to build an iterator out of it, but meh, who cares.
 

« first day (1853 days earlier)      last day (3111 days later) »