« first day (3453 days earlier)      last day (1478 days later) » 
00:00 - 20:0020:00 - 00:00

12:21 AM
-41
Q: Upcoming Feature: New Question Close Experience

DesI’m Des. I’ve been here at Stack Overflow for a little while now (4 years and some change) and just recently started working much more closely with the Public Q&A product team as Director of Product, Public Platform. Working within Teresa’s organization, I'm responsible for setting the overall st...

Let's hope "OP's edit reopens" remains a plan
 
1:00 AM
@AndrasDeak I feel bad for this user who is one of few gold badge holders in a small subset of a language like PyQt5.
 
wim
1:28 AM
I also feel bad for PyQt users :D
 
AMC
I forgot to mention earlier
 
@wim na, it's nice. QGIS users need to make plugins
 
AMC
I have finally released my attempt at a canonical/reference Q/A for the classic "web scraping dynamic content using requests" issue: stackoverflow.com/questions/60904786/….
And I also just found the first question where it applies, stackoverflow.com/questions/60922741/….
 
1:44 AM
@AMC Why not include some some code in your answer, something like a working solution with selenium?
 
AMC
2:01 AM
@Dodge That’s one of the things I considered, although I was worried that the answer would become too lengthy, and/or entrenching on other questions.
If I include working code with Selenium, should I cover inspecting the network traffic in order to be able to make API (?) requests directly?
 
I have seen many lengthy canonical posts, coldspeed is a user who was once in this room often who did many such Q&As on pandas stuff, always long and comprehensive. This is different, but the person who needs this canonical also probably needs an example of something that works
 
@AMC I think that's a good case for short answer to question, then asking and answering your own question to have a more comprehensive canonical. This avoids posting your answer as a dupe target for other questions which your answer does answer, but to which the question you answered isn't really a good dupe for.
@Dodge What happened to Coldspeed?
 
@toonarmycaptain they are here sometimes still, something about working at google I think I read, but for the record, I have never communicated with this person directly and don't want to make guesses about their current endeavors, just know they did many highly upvoted canonicals.
 
@Dodge Fair enough. You doing ok? In lockdown, or working?
 
I'm good, our city just issued an official lockdown a few hours ago. I work part time at a federal crop research facility which issued work from home two weeks ago. Other than that I am on a fellowship for grad school and am a distance PHD student so any movement to remote courses at Texas A&M changed nothing for me.
@toonarmycaptain Having a legit excuse to opt out of anything social for the past few weeks has been really nice, actually. How are you now that the school districts are all closed?
 
AMC
2:22 AM
@toonarmycaptain This avoids posting your answer as a dupe target for other questions which your answer does answer, but to which the question you answered isn’t really a good dupe for. I’m getting lost, can you put that differently?
I do understand the main point though, I will include a full solution using Selenium tomorrow ;)
 
@AMC this is a much needed canonical, if you get it right and people start to use it I think it will be well received and frequently upvoted
 
@AMC What I mean is: An xyzabc answer to "How do I do x with a?" risks people listing your answer as a dupe to "How do I use cb to do y?". Your answer might be an answer to the second question, but the question you originally answered isn't really a dupe.
@Dodge You're not in FW anymore?
 
AMC
@Dodge I’ll give it everything!
 
@toonarmycaptain No, Lubbock area for many years
 
AMC
@Dodge Speaking of being much needed, do you have any idea whether it’s as much of an issue in other language tags?
 
2:28 AM
@Dodge Well, we've been closed for the last two weeks of classes following spring break, so it's three weeks so far for us. I'm...with her pregnant and the kids mostly locked indoors because it's been wet, it's been a bit rough. Trying to establish a rhythm for them, and for us that keeps the house livable, which setting time for her to make videos for teaching online, and my coding/studying/sleeping.
 
@AMC No, sorry. Anybody doing web scraping in javascript probably does not have this issue because they understand web pages, c++ people are probably too smart to not get this either, probably just the amateur python group that this confuses, IMO
 
AMC
@toonarmycaptain Alright, I will revisit this explanation once I’ve slept. Just to be clear, you are in favour of adding a Selenium example?
 
Anyone having trouble to focus? I've noticed an anxiety increase due to COVID
 
@Yamaneko Focusing has never been easy for me
 
AMC
@Dodge Okay, good to know.
 
2:31 AM
@Yamaneko I'm having trouble focusing because I have ADD, small children, and a house to maintain semi-solo - does that count?
 
AMC
@Yamaneko Anyone having trouble to focus? On a website about programming, probably, yeah ;)
 
Sure. I'm just saying that the book-length answer should be to a question requiring that answer, rather than a 'one page' question. Because it will be listed as a dupe target to other questions that are really 'another page' in that book.
My analogy bone is failing today.
@Dodge Hmm, dunno why I thought you worked financial stuff in FW :s
 
@toonarmycaptain Ha, not me for sure! And thank goodness, being a financial guy is probably not too much fun right now, unless you are just getting into the market :P
 
@toonarmycaptain Sorry to hear that. I hope it gets better. How are your kids doing during this isolation?
 
@Yamaneko They're ok, they want to see my inlaws, my oldest wants to go to school, and wants us to do homeschool like his actual school. They see my family via videocall regularly, so socialising that way isn't unfamiliar, at least. Other than that, they're just bouncing off the walls.
 
2:41 AM
@Dodge How do you usually handle this?
@AMC Yeah, it will be a little biased, haha
 
Hi, anyone knows about Django? I have a little question
 
@Yamaneko I'm either too focused on not focused enough. I don't do anything specific other than exercise. I try to be as organized as possible so it is is easy to switch between tasks.
 
@toonarmycaptain And it's hard to keep an influx of indoor activities to keep them from bouncing off, specially while also working
 
comes back from checking phone notification, distracted listening to BigBangTheory wife has on tablet helping her go to sleep, and finding the typo in a failing unwirtten/incomplete test whose only line is monkeypatching a variable.
@Yamaneko Mine are 4ish and nearly 7, and with my wife pregnant, keeping them both occupied while homeschooling is kinda a 2 person job, so juggling housework is challenging. But we're making it. One of these days they'll learn by experiment why we tell them not to touch the oven... Science.
 
AMC
@toonarmycaptain My analogy bone is failing today. Don't beat yourself up too much, my entire brain is apparently failing.
 
2:54 AM
[I should note here, before CPS is called, that while I have a very dry, dark sense of humour, much like where one should keep scotch, that I will not be allowing my children to burn themselves on the oven.]
 
AMC
If I'm understanding you correctly, you're in favour of a Selenium example as long as it is kept short/concise?
 
@AMC I haven't checked out what you're referring to, but I'm always in favour of short working examples.
 
AMC
@toonarmycaptain Alright, then I'll share a draft of the answer tomorrow :)
 
I should note that all I know about Selenium is that it's used for automating browsers/testing webpages, I think?
 
3:02 AM
mentioning here, Debian's Biohackathon Apr 5-11 is seeking volunteer contributions, there's a section which seems to target Python people with no need for any bio/med/covid-19 knowledge phoronix.com/…
 
@toonarmycaptain Wow, that's a lot. I have one 3 year old and I already think teachers should get a million raise. About the oven, lol, only with empirical evidence
 
@Yamaneko As someone who staffs nurses clinics in schools, and is married to a teacher, I agree with you ;)
 
@tripleee well done :P
 
only now noticed the starred link to another chat room, sorry for the noise ...
 
3 is the age I decided to return to work after being at home for the first 3 years with my oldest and first year or so with my youngest.
 
3:16 AM
am dealing with dronekit, which control 20 unites of Drones. I've everything works fine but there's a point which is complicated. I've arranged safety land points and allocated the drones to land on the nearest point before the battery die where i keep check the nearest location and time taken to arrive to it.
then i raise the order for the drone to quickly move to location and drop off. with that way, i keep checking the battery only once it's <= 10%.
now am having issue, the time taken for reaching the nearest drop-off location will be vary for each drone depending on the weight of Sterilization materials
anyone have a logic for controlling this ? I've no way to measure the weight during Pumping.
 
sounds extremely specialized ... can you estimate the load e.g. from the speed it travels (assuming you have the ability to track its location)?
maybe add a maneuver like ascend at maximum speed and measure how long it takes to go from one altitude to another?
 
3:36 AM
@αԋɱҽԃαмєяιcαη You should always assume max payload for logistic planning in this case given that you have no real way to measure payload
 
@tripleee Ascending at max speed when battery is low might drain more battery than desirable?
But reducing power by 50+% and observing rate of descent/drop distance compared to stationary altitude might yield a reasonably straightforward calculation? If you've no altimeter, but a camera, comparing size of objects before and after might not be too hard? Not that I've done any image processing.
 
I guess I was assuming you would have the battery fully charged after loading
 
yes, all units is charged 100% on specific hour of each start day
 
so they charge once and then fly multiple missions with different loads?
 
Yes
@toonarmycaptain using camera or sensor will be a big way. and usually it's ends with 75% risk
 
3:53 AM
@αԋɱҽԃαмєяιcαη Might be safer to use large error margins, or use initial upward acceleration on takeoff (predictable upward acceleration) to estimate weight.
 
can you estimate the load just from how much lift you need to stay at the same altitude?
 
@tripleee yes i can do that. I've been doing that all day today
 
as often is the case a good first baseline would be to estimate how much you really gain by optimizing this relative to just pessimistically assume maximum load and take it from there
 
@toonarmycaptain I think to use drone weight plus measure the pump rate per hour. then move to @tripleee way
 
@αԋɱҽԃαмєяιcαη What do you mean by pump rate? Are these gas-powered drones?
 
3:57 AM
I've 5 drones off 20, where was fall like a rain in car park today :D:D
@toonarmycaptain i mean pump rate for Sterilization materials
 
@toonarmycaptain hardly if the question is how to get them to a recharge station ... I was asking myself the same thing, there are several terms here which should probably be clarified or rephrased
 
4:13 AM
I've turned on the emergency mode. with recording the take-off point and raise a cmd to turn auto-pilot to nearest drop-off points where I've actually saved the point within the auto-pilot map. i will keep monitor it for the next 1 hour and see
 
wim
@AMC I agree with Dodge and toonarmycaptain - people will be annoyed if you use this as a dupe target because the answer does not demonstrate how to solve issue, only identifies what the issue is exactly
probably most visitors already know that the issue is because of js but just want to see some tools/demo about how to proceed here
I wonder if there is a service similar to httpbin.org but for ajax stuff...
 
@wim 99.9% of users which is asking web-scraping question, they actually have no knowledge about it. it's just a homework assignments . they even don't care about explanation ! they just want a code to work. i see a daily questions on different targets by the same OP
something like that
 
wim
Maybe also "dynamically generated" is a bit of a silly terminology to put in boldface. After all, the html from the initial request/response is just as dynamically generated too! But I don't know a common term for the stuff injected into the DOM via ajax, perhaps "asynchronously generated" can be an improvement? (after the "a" in ajax)
 
it can be yes.
scrapy already have addressed multiple cases like that
 
wim
4:30 AM
by the way, I also think selenium is not the goto solution here. It's a last resort, if you can't use an API or reverse-engineer where the js requests
 
selenium is usually the last resort. i usually advice op to be far a way from using it
also there's questions where the OP just don't know the basics of code. where his/her main issue is not about web-scraping itself. something like that question
You know what, i think that the community should restrict newly questions within circle of 3 votes to decide if can received answer or not. that's will avoid much duplicates during each day.
better than having question to be answered then it's marked duplicate and closed.
 
4:46 AM
 for k,d in df_new['text'].iteritems():
        for v in d:
            if 'abstract' in v:
                #print(v['abstract'])
                df['new_abstract'] = v['abstract']
this code is giving only last value in all rows
df_new and df are pandas dataframe
at last line i m trying to assign values of dict abstractkey in new column named new_abstract
can someone help me what i m doing wrong?
 
iteritems() is actually removed ? now it's items()
iteritems() is a generator, you know that yea?
 
nope
 
but printing was working fine
 
you are using Python 2?
 
4:55 AM
python 3
items() also giving same
 
you should use items() since you are using Python 3.
 
it is still using in latest pandas version
 
Ah ok you are using pandas methods.
i thought that you are using dict methods itself.
 
so what is wrong with my code then?
 
you expecting the change to be done without append or inplace=True ?
 
5:00 AM
how inplace will be used as parameter and append is used on list
 
@loving_guy syntax error, is that meant to be a question?
 
i think so
syntax error how?
see method 4
 
5:15 AM
@loving_guy what am trying to tell you, that you are doing inner loop without append! so you will only get the last value ! that's normally.
for item in range(1, 11):
    pass

print(item)
item now will give you an output of 10 ! since it's the last value on the loop
provide a valid MCVE will help us to guide you. since we don't know how the data looks like in your end.
 
pastebin.com/2r2RHB4A here is the data
it is the list which has dict
 
5:36 AM
@loving_guy how X and Y sounds like the headline of an instruction but I guess you mean that as a question, probably something like how does X work and probably something like what is the Z of Y in W but we really can't guess the missing words
 
np i solved it
thanks bte
btw*
 
would memoization be of any use in recursive factorial function? like this:
def memoize_factorial(f):
    memory = {}

    # This inner function has access to memory
    # and 'f'
    def inner(num):
        if num not in memory:
            memory[num] = f(num)
        return memory[num]

    return inner

@memoize_factorial
def facto(num):
    if num == 1:
        return 1
    else:
        return num * facto(num-1)

print(facto(5))
it always returns facto(n-1) which would not be in the memory right?
 
6:04 AM
memoization doesn't really do much if you're only running it once, correct. But if you were to run another factorial, or the same factorial again, then you could see some gains.
since then, all those previously-calculated results would be available for reuse
 
6:32 AM
a good example for memoization are the Fibonacci numbers, since there is a duplicate dependency on previous elements.
though many classical recursive tasks are better handled co-recursively, which Python best does via generators
 
i added print(memory) in the definition of inner() but it prints empty dictionary each time...why?
 
that's because your cache isn't filled until the function actually returns.
if you run facto(5) twice, you'll see it is not empty by then
 
but in Fibonacci case it shows even if i run only once.
 
that's because facto only has a single dependency on its predecessor, whereas fibonacci has a double dependency
since fib(n) = fib(n - 1) + fib(n - 2) = fib(n - 2) + fib(n - 3) + fib(n - 2) = 2* fib(n - 2) + fib(n - 3). Note that 2* for the predecessor, which means you can read it from the cache once.
Note that without prediction, n accesses have a maximum cache hit rate of (n-1) / n. So for 1 access (factorial), you have 0 cache hits. For 2 accesses (leading fibonacci), you have 1 cache hit.
 
One thing i really like doing when I want to really observe the tangible effects of caching in toy examples like this: deliberately adding a time.sleep() call in places with a message, just to really drive across how often things have to run, and essentially what kind of an impact caching can potentially make. Since these tasks run so quick, you sometimes miss out on the potential benefits of caching till you scale the load up
For example, run the following
@memoize_factorial
def facto(num):
    if num == 1:
        return 1
    else:
        print("sleep 0.5")
        time.sleep(0.5)
        return num * facto(num-1)

print(facto(5))
print(facto(6))
(with time imported)
 
6:51 AM
yeah, printing which function is actually run can be really helpful to understand the benefit. E.g. if you run facto(5) twice, the cache hit rate is still abysmal - only 1 hit for a single item. That's because the entire benefit is that the entire chain of even looking for facto(4), facto(3), ... is completely eliminated.
 
Indeed, functions where you have more than one recursive branch with overlapping workloads utilize caches much better, since they actually benefit from the cache even during it's own computation
 
melon MisterMiyagi and ParitoshSingh
 
7:35 AM
cbg
 
8:00 AM
@wim that's what we talking about. no need for scrapy even
 
@αԋɱҽԃαмєяιcαη scrapy slows you down? Really... for a very simple page - probably... but if you're wanting parallelism, throttling and extendability and convenient navigation crawling... writing all that by hand is going to slow you down more sticking to just requests etc...
 
am about that from scrapy.utils.response import open_in_browser
why i do i need to visualize in the browser ! if i can do that with requests ?
 
err... not getting you?
 
well, you just voting for scrapy? yes?
am telling you why i do need to use scrapy, if i can do it with requests without open the url in browser ?
same like selenium !
 
I mix'n'match things when scraping... just saying that scrapy slows you down is a rather generic and not correct statement
you know you don't need to open it in a browser, right?
 
8:12 AM
i know that, i use scrapy for around 2 years
 
right... so not sure why you're mentioning open_in_browser then?
 
but i vote for requests for that question. scrapy will be powerful for multiple pages. not for just a single page.
 
yeah for that one - I agree requests is better... but I don't agree with what looks like a generic "scrapy/selenium" slow you down
in this case - they're just not needed... but if you give the impression they slow you down when in fact they'll just not necessary...
 
a good point, i will edit it.
@JonClements done
 
and please start using params= - seeing query strings in URLs when using requests just makes me go "arhghghghgh!" :p
 
8:17 AM
just lazy hahaha. copy/paste instead of separate them. :P
 
and Main should really be main... in fact, heck, just cheat slightly there.... def main(url, **params) and then use params=params in your .post and call it as main('https://heavens-above.com/StarlinkLaunchPasses.aspx', lat=50, lng=12, loc='Somewhere')
better naming convention, avoids a query string in your url and thus much more easily editable later (as well as clearer as to what it's actually requesting from that end point now...)
 
i did remember you while i was typing that part
:P
@JonClements edit whatever you want, i will accept it. :P
 
oh and .findAll should be .find_all :)
 
old school , such as findNext became find_next :P
@JonClements you were a moderator before?
 
maybe? :p
 
8:27 AM
@JonClements you never relax me in answer :D
 
am I supposed to :p
 
Okay, i will die now :P ahaha
 
seems overly dramatic!
 
why not? some drama is better than action all day
def blah(url, **params):
    r = requests.get(url, params=params)
    ...do...


blah("https://www.site.com", id=1, play=2)
 
isn't there currently enough drama? :)
 
8:34 AM
you know, i found it's more clear
zZzZZz i remember i've asked you about the binary one time ?
 
huh?
 
I were asking you about binary before, am having issue with things during learning. for example, when i read about binary and encoding, i keep taken time and read deeply into things which taken time. the same like when i go about regex, i keep read deeply about it. i don't know if am in correct track ? shall i continue in same way. i feel that am giving much look into things?
 
looking into things is a good thing... however, it is easy to try and digest too much at a time... generally, read up enough to solve a specific problem, make a note of it, and then it'll come in handy next time to piece together a jigsaw regarding that area later
 
0 0.63 w1
1 0.53 w2
2 0.55 w3, i need a python .where 0.63 will be replaced by w1 , 0.53 by w2 , and 0.55 by w3 . this is reference data frame . this data set will always keep on changing can be w1 to w100. pls guide
basically i can do manually by np.where but i need to do dynamically
 
@Nabi so is that a DF with 2 columns?
 
8:46 AM
At some point I need to stop convincing myself that regex doesn't exist. "Catastrophic backtracking" has an exciting name, I could probably get one board if all my screw ups while learning make me feel like I'm in a Die Hard film
 
yes
@JonClements yes
 
@roganjosh it's a very useful tool for what it's supposed to do - it's just one of those that's overused fairly often
 
@NabiShaikh what is the rule for assigning w values? The first time a value is encountered, it gets a new label?
 
@roganjosh so basicaly i have two data frame one is this one i shared , anouther one is with lots of decimal points , where i need to assign with lots of decimal numbers where i need to w asihned column to it ..
 
@Nabi and you have another DF with 0.63/0.53 in a column and you want to get the w1/w2 values?
 
8:50 AM
@JonClements i have other data frame , where one of the column shave lots of numbers between 0 to 1 which is probability score , i need to assign these numbers with w1 to wn category , whatever the w would be there in the data frame
 
What does "lots of decimal points" mean? Is this an issue with joining on floating point numbers?
 
@roganjosh i were escaping from using it. but now i loves it :P
 
@Nabi okay... so sounds like you should create a lookup... so something like: lookup = first_df.set_index('col1')['col2'] (where col1 is the number and col2 is the w value)... then you can map it... so w_value = other_df['some_col'].map(lookup)...
 
@roganjosh closed
 
thanks :)
 
I do have sympathy for someone spending 2 hours on the typo... I just wish people would pay more attention to tracebacks when they're learning :/
@MisterMiyagi closed
 
9:28 AM
@roganjosh btw, the previous question from is exact dupe, so can be closed too (linked by ahmed)
 
Done
 
Well done guys :D a great hammer today
 
It's our own little Oprah episode. <pointing wildly> "You get a close, you get a close and YOU get a close!"
 
Oprah sound :O, i imagine how it will be :D
 
needs more focus (or about 3 dupes) stackoverflow.com/questions/60927473/…
 
@αԋɱҽԃαмєяιcαη what's the duplicate?
 
@roganjosh I'd rather a car but okay :)
 
Hey, you get what you're given in times of austerity :P
 
189
Q: HTTP requests and JSON parsing in Python

ArunI want to dynamically query Google Maps through the Google Directions API. As an example, this request calculates the route from Chicago, IL to Los Angeles, CA via two waypoints in Joplin, MO and Oklahoma City, OK: http://maps.googleapis.com/maps/api/directions/json?origin=Chicago,IL&destination...

ah, i retracted my close vote to pass the correct url, that's why it's not shown there.
 
 
1 hour later…
11:18 AM
/me watches the tumbleweed
 
11:28 AM
arghghg... need to boot to windows for some C# I'd forgotten about
 
I thought C# did both. Or was that only .NET core?
 
11:48 AM
I've used C# on MacOS, but I'm being told the system bindings are just a sad joke compared to Windows.
 
12:07 PM
can anyone answer this question (stackoverflow.com/questions/60900825/…)
 
Uhh.. what? especially the last paragraph: "If you could upload yourselves by the help of marker please put your earlier version file as veto right. You can copy yourself. Also predict yourself in a simulation so you don't become an evil overload tyrant. I already builded my marker but most of them choices evil that why I want government help us in this situation"
 
I think that question was written by an artificial consciousness
 
@smci Google translate FTW
 
@roganjosh back into Spanish, we guess.
 
A valid point, though. If I could predict myself, I could potentially be an evil overlord tyrant
Oh, I think they're saying the opposite. I'm an evil overlord tyrant until I can predict myself?
 
12:46 PM
@smci Am I the only one slightly unsettled by the notion that the OP already did this and all projections showed they are pure evil?
 
@MisterMiyagi ...can you understand their reference to Google Glass? "We have two Google glass, one for img world second for letters and on screen typing."
 
Sadly not. It falls under the "maniacal rambling" category for me. Unlike the "build a marker" comments, which stir an urge to grab a plasma cutter...
 
1:02 PM
Ah but they still Used Google Glass, not Apple AR or Vuzix or whatever brand...
 
needs one more del vote (20k+)
 
It's gone.
 
1:27 PM
Cbg all
Thank you @smci for posting about that AI question. I want to star the question as one of my favorites, will that impede normal SO housekeeping?
 
2:08 PM
brief cbg
@MisterMiyagi meh, some .NET stuff is fine with the MONO framework on linux for instance, but ultimately, if you need to do Windows... then err well, no other choice really
 
2:32 PM
I'm surprised people don't repost JoyofTech cartoons more... it's sometimes brilliant.
 
fails this test "abcba"
its in the last paragraph the error
but i have checked the for loop
didnt fix the problem
 
@Permian A palindrome is any string s for which s == s[::-1]. I don't see that pattern anywhere in your code.
If you feel the need to reinvent the wheel using two plain for loops and one double-nested-extra-double-if loop, please at least use speaking variable names.
Having checked "the for loop" when there are in fact four of them is not exactly helpful to exclude sources of error.
 
this s == s[::-1] fails and i cannot remember why
 
You cannot remember why?
Does it fail programatically or just doesn't meet the actual criteria?
 
3:22 PM
@Permian Then find out why.
 
Sam
Hey all, I have a Pandas question which I've written out as a minimal example here repl.it/repls/IndelibleAssuredSuperuser if anyone has a few moments
Not sure how I only return the row-max after doing a value_counts() operation
 
user11585758
Hi guys
 
user11585758
One help please :)
 
3:39 PM
Regex question: I'm trying to match a counted string of the form integer:n_characters_where_n_equals_the_leading_integer so that "3:abc" matches but "4:abc" does not. I tried (\d+):.{\1} but the \1 is not being interpreted as the desired character count. (I could do it with pyparsing, but must regex if possible.)
 
My gut instinct is that conventional regex can't do that kind of thing.
re is a couple pegs above conventional regex, but even so...
 
user11585758
regex
 
@PaulMcG this reminds me of Kevin's regex number parsing a while back, and that involved hand-coding each digit (to an extent)
I don't think you can do this reasonably with regex
 
I wonder if third party module regex has any useful toys here? None off the top of my head, but I'm hardly an expert
 
Trying regex module now
No go - at least not in that form. Looking at regex module docs now to see if secret sauce is required.
 
3:44 PM
@Sam sorry, I don't think I follow the desired output
 
user11585758
re.match(r'[0-9]:abc', name)
 
That's actually a good minimal example to show the limits of a context free grammar. Better than counting parentheses imo
 
@mathematics That pattern matches "4:abc", but it's not supposed to
 
@sam it looks like maybe the groupby is done in the wrong order (logically speaking; I'm not sure you need to chain them)
 
PaulMcG should create his own regular expression module, with even more bells and whistles than both re and regex combined. I notice the name regularexpression is not yet taken on pypi...
 
user11585758
3:46 PM
paul told so that "3:abc" matches but "4:abc" does not., it matches . Isnt it!!
 
If you're saying "I thought paul was complaining that his existing approach matches 3:abc and does not match 4:abc, and this is undesired behavior, and it should match both", that is not my interpretation of the requirements
brb
 
user11585758
thats i got what i know :D , Hope it helps :)
 
@mathematics - you misread my statement then, or perhaps just read it a little too quickly. I need a regex that will not match "4:abc", because there are only 3 characters after the colon.
 
user11585758
ahh, sorry, I am trying to solve it
 
user11585758
its actually hard problem
 
3:52 PM
Have you considered a two-stage approach, where you first scan for \d:. and then compile a regex for that specifically?
 
If this was for, say, the tokenization step of a parsing project, then having a one-pass approach would be quite desirable
 
Hmmm, the 2-pass scheme might work, and aligns well with my try-brute-force-if-all-else-fails sensibilities
 
"declaring the length of a string, then the contents of the string" is a not-entirely-unheard-of encoding scheme, so I wonder if there are any pre-existing solutions to this problem
 
I don't think they are called regex.
 
The Reverse DenverCoder9: the problem has been asked and satisfactorily answered, but in a place you'll never find it
 
4:10 PM
@Kevin Not sufficiently indicative of such a module's bells-and-whistle-ness, I think I would go with something like superduperregularexpression
 
user11585758
Can we solve this using function with regex using tricks
 
Apparently Pascal stores its strings with a "size byte" prefix, which is kind of like the encoding being discussed here. These are called p-strings or Pascal strings. Unfortunately, googling "p-string regex" gives lots of irrelevant results where the word "string" follows any word ending with "p". And "pascal string regex" merely gives results about doing regular expressions in Pascal.
 
@PaulMcG irregex
 
@mathematics Your guess is as good as ours.
I did find a single relevant looking result: how to match pstring?. TLDR: you can't do it with conventional regex.
 
not with that attitude
 
4:14 PM
True. And also not with any other kind of attitude.
 
Hmm... self-modifying regex...
 
I'm growing ever more curious about the use case where "regex on crack" is more suitable than any other solution :)
 
I'm seeing how the 2-pass thing might work in my code. I can easily scan for \d+:, then build the intended regex. Fortunately this only occurs at one place in the much larger expression.
 
user11585758
guys do you know how to return given matched number in pattern
 
user11585758
like 1234:abc

I want to extract 1234
 
4:20 PM
yes
 
@mathematics - it's called a "capturing group". Go to regex101.com where you can practice many different features of regular expressions.
 
user11585758
how to check word after 1234:abc , i want to return abc
 
You can also do that with a capturing group.
 
@mathematics please use a paste service like dpaste.com to post large blocks of code
 
@Kevin I know this problem also from sockets, where a size-header precedes the messages. However, these situations always clearly mark the "start of header" so there is no additional scanning for them. Similarly, a p-string content would be directly read as pointer[1:1+pointer[0]] because the length is known to be the leading data.
hm, is there a regex library that actually works on streams? so that a (\d:) pattern suspends matching, returning the captured data and the stream at the current position?
 
4:39 PM
@MisterMiyagi and that's bytes, right?
I remembered old-style fortran binary formats injecting the size of the data with each write, but I didn't mention this because it's not about string parsing
 
@AndrasDeak yes, good old machine fodder. No Humans Allowed.
@AndrasDeak That's an interesting point. size + content is basically every boxed format, such as ROOT, HDF5 and... pickle.
 
I'm using Jupyter Notebooks on Debian WSL and it's different from Windows
 
Hello
anyone here have any experience with google api?
 
just ask your question. If it sounds familiar, we'll chime in
 
I have a csv list of comapny names but I need to get all the address.
was wondering if it was possible to pull it from google with just the name of the company
 
4:45 PM
It may be possible. What API are you talking about specifically?
 
@chillinOutMaxin Does google API have documentation by any chance?
 
I've done something similar using google maps, but it gets tricky if there are multiple companies by the same name
 
ive only done some brief search on the subject to see if it was done before. Figured I would ask here if anyone had any experience with it. @inspectorG4dget do you have a list to any information on how you did it?
 
I don't understand what you mean by "a list to any information". Could you please clarify?
 
4:48 PM
yo, regentjosh
 
congrants! 🎉
 
sorry. Meant to say link. its been a long day
 
@PaulMcG Obviously you can do it with two capture groups, and just post-process candidates to check whether integer == len(characters). As to a regex-only solution, can you put bounds on the values of integer? 1-9? If it's small you could simply expand all possible regexes. Yes this is same question and answers as Kevin's previously-posted regex question.
 
@AndrasDeak Yo :)
 
4:55 PM
@roganjosh congrats! where are the italics?
 
refresh the page
 
thanks
 
undercover RO
 
@roganjosh Congrats!
 
@Permian No it doesn't fail; show us a counterexample. s == s[::-1] works on all strings, even ''. You don't necessarily need the whole dynamic-programming 2D array of booleans for all possible start- and end-indices.
 
5:03 PM
@MisterMiyagi Thanks :)
 
@roganjosh Congrats, you've been elevated to the star police ;-)
 
OMG, there is SO dark mode now!
 
As long as I get a blaster that goes "pew pew", it's all been worth it @smci
 
aarghhh, chat still uses the light theme. I need new eyes, brb
 
5:09 PM
does the main site have a dark theme now?
or just user scripts?
 
yup, main has dark theme in beta
 
oh
I just reloaded the main index
 
@roganjosh What shape is a star chamber, anyway? (When the Michael Douglas film came out, I thought the name derived from the shape of the room, but no)
 
and yah, now chat is quite jarring
 
5:25 PM
@MisterMiyagi I'd like this in chat.
 
5:36 PM
@MisterMiyagi nice, they've been resisting that for many years, they even said no a few months ago
@Aran-Fey there's still rlemon's dark theme...
now more valid than ever
 
AMC
@wim I agree that adding some information on Selenium is good, but I'm not sure I agree with the idea that most visitors already know that the issue is because of js but just want to see some tools/demo about how to proceed here
In my experience, at least, the person asking the question is not aware of what the issue is.
@wim Last time I did any research, the term "dynamically generated" seemed to be the most common, I'll try to find something better.
 
6:07 PM
@smci It appears that I'm gonna have to watch this one to try reply if I want to be witty
 
AMC
@αԋɱҽԃαмєяιcαη Ah, that's another issue entirely, no canonical/reference QA can help with that.
@wim Looks like I'm going to have to use a different website, twitch has an API, so an example showing that is really only useful for that specific website, and reverse-engineering the requests is proving to be a real pain.
 
@roganjosh No, no, that was a fairly missable 80s film. The only connection is it took its name from the 15th-17th century English secret court. Which I mistakenly thought was due to the shape of their chamber.
@toonarmycaptain I first thought you mean you wanted MM to invite the OP of that vague question here to discuss it... lawks no...
 
Sam
@roganjosh yeh, this managed to do the trick in the end: frame.groupby('col_a').apply(lambda x: x.col_b.value_counts().index[0])
 
@wim technically it's an answer...but worthy a delvote
Is it blocking the deletion of a dupe?
 
wim
@MisterMiyagi I thought it was an early april fool's joke at first
 
@wim Your end-goal is to delete the entire question?
 
wim
6:38 PM
nah, I don't mind the signpost
if the roomba decides to delete it then so be it
@AMC I charitably assume most visitors are not as clueless as most users who actually post
I suspect for every poor question posted, 100 people were able to find what they wanted without needing to post anything
 
AMC
@wim Good point, I hadn't considered the people who might stumble upon the question at a later time.
 
@wim Even a vaguely-written question with an image of a plot is a good resource for finding out about np.meshgrid. I didn't know about meshgrid for ages.
 
wim
yep. I don't know who delv on the question (wasn't me)
 
7:13 PM
@roganjosh: Now the coronavirus restrictions might take out the cherished Easter egg. This means war! (Honestly it sounds like a Boris-Johnson-grade fake headline from Brussels. More innocent times.)
 
@smci We just have to relax the rules on smash-n-grab. Shops can buy them in but can't sell them.... well, just break the window and take the eggs. Perfectly cromulent
Sounds like quite the hunt to me
 
wim
7:38 PM
 
7:49 PM
3 hours ago, by MisterMiyagi
OMG, there is SO dark mode now!
@smci interestingly, in the States, "Easter egg" usually refers to an actual egg (raw or boiled) that has been dyed in some pastel color. I think this kind of egg we would call "chocolate egg" or something like that.
 
00:00 - 20:0020:00 - 00:00

« first day (3453 days earlier)      last day (1478 days later) »