« first day (2112 days earlier)      last day (3061 days later) » 

13:00
but the answer doesn't work
Err... it shouldn't unless you've installed a backport or a module called ipaddress :)
I was going to suggest going into the source code for base64.py and just copy-pasting the a85encode definition straight into your script, but it looks sufficiently complicated that it would be easier to just upgrade from 2.7 to 3.X.
@eleanora no it doesn't. What does import ipaddress; print(ipaddress.__file__) print?
You either installed a 3rd party library or have a local script called ipaddress.py.
@MartijnPieters ah.. turns out I have pypi.python.org/pypi/ipaddress
@eleanora right, was about to point to that. :-)
13:01
nonetheless base64.a85encode doesn't work
so I am still stuffed :)
"Try to do it this way" and "use StringIO" still don't explain the answer. Answer why you do it. — davidism 30 secs ago
I have no idea why this is such a hard concept for an 18k user.
@eleanora I think pypi.python.org/pypi/mom has a base85 encoder.
Some more grump fuel:
in SO Close Vote Reviewers, 6 mins ago, by Tunaki
Is this a new type of link-only? http://stackoverflow.com/a/38631621/1743880
link-only post with SOD link to example
13:03
I get "AddressValueError: '192.168.0.1' (len 11 != 4) is not permitted as an IPv4 address. Did you pass in a bytes (str in Python 2) instead of a unicode object?" currently
that's old!
@AndrasDeak nuked
Thank you:)
Trying to score doc badges, I suspect.
That didn't go down well for them ;-)
so my error message doesn't seem obviously related to missing base64.a85encode
poor things:P
13:05
any ideas?
*sheds a tear*
I just copied and paste the answer to stackoverflow.com/a/38633276/2179021
Morning cabbage.
ipaddress.IPv4Address("192.168.0.1") fails
:(
@MartijnPieters Just noticed links to docs have a little icon thingy... :)
13:07
wow! your answer has a great added value! :) — MaxU 4 mins ago
I can't tell if they're being sarcastic.
ok I solved one problem
from future import unicode_literals
is needed
now I get AttributeError: 'int' object has no attribute 'to_bytes'
@eleanora yup... that's not in Python 2.x - use the .packed attribute
@JonClements hmm.. could you spell that out for me please? Sorry...
@Withnail for your learning perusal: scipy-lectures.org (cc. @Andras, @JRich, @DSM for interest)
@davidism I'd say they're being sarcastic.
13:14
@eleanora similar to my comment instead of the answer's .to_bytes...
Some people get really salty about being asked to add effort to their answers.
What is a closing paren? — Maartenww 12 secs ago
Ummm... not sure if extremely beginner or trolling...
@JonClements ok.. still doesn't work of course :)
What is the sound of one paren closing?
@Kevin the sound of one paren opening, in reverse.
13:18
@Kevin the sound of someone with OCD letting out their breath.
@MartijnPieters This answer answers the question without answering the question. Good.
@MartijnPieters Did you just do the Q: "How long is a piece of string?" A: "Twice half its length" trick? :p
Where did i forget it? — Maartenww 34 secs ago
Umm.... seriously?
@JonClements half the same string doubled.
This is the sound of a few closing parens: sunn.bandcamp.com
@JonClements I'm praying it's a troll.
13:20
Where is a thing that never existed? This guy is a zen master.
@JonClements apparently so, the comment has been edited now.
@KevinMGranger sounds like opening to me, actually: sunn.bandcamp.com/album/v-a-jukebox-buddha
He's still getting the same problem? Umm... whose got the crystal ball today?
My Magic 8 Crystal says "error in the part of the code he didn't show us"
anyone here?
Yes. Or is this another zen riddle?
13:22
nope
.net a good career choice?
Can anyone really be said to be "in" a chat room? It doesn't exist in physical space.
@user3413046 this is the Python room, not the .Net room or the "career advice from cold open" room
I am of this chat room.
"But there's no .net chat room"
Calling it now.
"Not our problem"
13:23
yeah
Calling the call.
Did someone call?
Or was that a closing paren making a sound again?
If an open bracket causes a syntax error in the woods, does it make a sound.
I have a job writing .net code. All of my coworkers also have jobs writing .net code. None of them have been fired in the last N years, so therefore .net coding must be a stable choice of employment.
I assume this generalizes to all .net jobs everywhere.
Ahhh... haven't seen a parse html with regex in ages :p
13:28
Lol that guy fixed his uneven parentheses by adding one to a comment on the if num1 % 2: line
I have a job not writing .NET code. I am not aware of any colleagues that write .NET code. I work somewhere people are quite happy. Therefor I assume that .NET developers must be abysmally miserable to explain why everyone I know not working in it being so happy.
I have no evidence to refute your "all .net devs are miserable" hypothesis ;-)
... ;_;
I have written some .NET code at my job and I'm occasionally miserable. Therefore, working on Thursdays makes you crave pizza.
If X, then Y. Z, therefore Q.
@JonClements any idea how to replace the a85encode part?
13:33
30 mins ago, by Martijn Pieters
https://github.com/gorakhargosh/mom/blob/master/mom/codec/base85.py
@JonClements To be fair to those people, it is afaik unknown whether the souped up regex languages provided these days actually cover all regular languages or not
It doesn't matter if they do or not, you shouldn't use regex to parse HTML.
@eleanora HTML isn't a regular language though... so you can't parse it accurately using regular expressions...
@JonClements that was a typo. I meant context free languages
I know that the regex module is fancy enough to parse context free languages. I can't recall if re can, too.
13:36
@davidism right but at least it's not provably impossible :)
@Kevin oh has that been proved somewhere?
I'll consider it provably impossible until someone releases a fully correct and maintainable regex html parser.
I ask because cs.stackexchange.com/questions/4839/… for example came to no conclusion
I'm pretty sure I had a link proving it on my old computer, but I didn't port my bookmarks over.
@davidism seems like a terrible challenge someone might accept :)
Basically you just need recursive patterns, which are AFAICT a fairly common extension to basic regex functionality
13:38
@Kevin a certain subset of tags don't need closing tags
@Kevin there is some technical detail explained at nikic.github.io/2012/06/15/… l. It seems obvious for context free and unobvious for context sensitive.
Hi friends, I need help,How to work this >>> y=10
>>> def printY(x=y):
... print x
...
>>> printY()
10
>>> y=20
>>> printY()
10
>>>
I don't know what you mean by "how to work this".
@Kevin it means please explain to me what is going on
Kevin knows how to work it.
13:40
Default argument is bound at definition time. You essentially name "10" "x". It has no relation to the thing named "y".
@davidism That certainly complicates things.
That's just the most immediate problem I can think of, there are sure to be others.
Pointless Friday project: construct a program that takes an EBNF grammar and outputs a recursive regex that matches legal strings of that grammar.
OK, wtf, now I have 2 downvotes after the other answer copied my explanation: stackoverflow.com/a/38637199/400617
Granted that regex might run in O(2^N) time or O(2 <N knuth's arrows> N) or something, but let's gloss over such inconveniences for now
> All right, I've been thinking. When life gives you lemons, don't make lemonade. Make life take the lemons back. GET MAD! I DON'T WANT YOUR DAMN LEMONS! WHAT AM I SUPPOSED TO DO WITH THESE?! DEMAND TO SEE LIFE'S MANAGER! Make life RUE the day it thought it could give CAVE JOHNSON LEMONS! DO YOU KNOW WHO I AM?! I'M THE MAN WHO'S GONNA BURN YOUR HOUSE DOWN! WITH THE LEMONS! I'm gonna get my engineers to invent a combustible lemon that's gonna BURN YOUR HOUSE DOWN!
Truly a man of inspiration.
@Kevin also a truly a game character ;-)
@davidism @kevin if any idea ....
@ReeganMiranda davidism already answered your question
13 mins ago, by davidism
Default argument is bound at definition time. You essentially name "10" "x". It has no relation to the thing named "y".
ohh thanks.....
13:54
@MartijnPieters I prefer getting inspired by fictional people rather than real people. Reality is so... Messy.
"You know that guy that singlehandedly resolved the conflict in outer Elbonia using nonviolent protests? Yeah, turns out he was secretly a serial arsonist in his spare time"
Cave Johnson admits on the record, without even being prompted, of his desire to set things on fire. He's a straight shooter.
Cheers for those, Fizzy, suitably bookmarked. I messed about with a classifier and got a 40% rate... so I probably need to refine that a bit. :)
Bio
Bio
Hello :)
I am new with python ( my second day of work with it) and I am lookinf for a way to handle missing values in a dataset
what kind of dataset?
Bio
Bio
14:00
I was looking in such tutorila, but I see that thy treat NaN values, but in my case i have banks
and are you using a library (like pandas)?
There should be a rule in hacking: "if a passcode is 4 digits, it's probably their birthday. If it is 5 digits, it's probably their zip code"
Bio
Bio
yes, iam using pandas
are there methods to handle this problem?
@corvid Most PINs are 4 digits but are usually completely random
so you want to change NaN to empty or 0 (and I mean empty or 0 as a question)?
14:04
An acquaintance of mine locks his phone with a 4 digit passcode. It's the year he plans to retire.
Bio
Bio
No I have not NaN, I have blanks
nothing written
I want to change empty by a value
Mine is the first four letters of the password I used as a kid.
@Kevin So 20xy where 16 < x < 65?
Yeah.
Speaking of NaN, my 4 digit PIN is NaN
14:06
@Bio We might need an mcve to diagnose this problem.
You're probably thinking "But my program requires an enormous proprietary data file to run properly". I acknowledge that this is a drag, but if you could provide a non-enormous non-proprietary data file of fake data that reproduces the problem, that would be terrific.
3
Agree with Kevin, this is going to be a lot of back and forth otherwise: might also check out Pandas Missing Data docs
@Kevin It's surprising the number of people who don't grok that
I find it ironically entertaining also the number of people who will happily include their 400 line script, but balk at adding 10 lines of test data -_-
cabbage, antti
I suspect that most people understand on some level that input data is important, but make their initial post without it in the hopes that someone can solve the problem without having to run the program at all, saving the question asker a lot of effort.
This isn't totally irrational. Some problems really are simple enough to spot check in this way.
14:21
yep, that's why there are plenty of questions in that are answered with link to .fillna
Bio
Bio
I have a csv file like this :
2015-12-14 16:20:00;292;HPH;430;ST GEREON;TURPE_HTA5
2015-12-14 16:30:00;289;HPH;430;ST GEREON;TURPE_HTA5
2015-12-14 16:40:00;299;HPH;430;ST GEREON;TURPE_HTA5
2015-12-14 16:50:00;292;HPH;430;ST GEREON;TURPE_HTA5
2015-12-14 17:00:00;72;P;;ST GEREON;TURPE_HTA5
2015-12-14 17:10:00;72;P;;ST GEREON;TURPE_HTA5
2015-12-14 17:20:00;80;P;;ST GEREON;TURPE_HTA5
2015-12-14 17:30:00;80;P;;ST GEREON;TURPE_HTA5
2015-12-14 17:40:00;80;P;;ST GEREON;TURPE_HTA5
2015-12-14 17:50:00;74;P;;ST GEREON;TURPE_HTA5
2015-12-14 18:00:00;72;P;;ST GEREON;TURPE_HTA5
Did you remark the empty values here
?
between ; ;
The fourth first line there is no problem, but the other there is missing values
I dont know if you understand what I mean
@Bio and why is that a problem?
If you're using the csv module to read that in, you'll get an empty column...
Bio
Bio
I dont know... My customer give me this dataset
There doesn't appear to be a problem. That's valid CSV.
Your client is probably doing something stupid like treating consecutive delimiters as a single column
Bio
Bio
14:25
Yes but I want to substract the 2 values (430 -292) and it cause problem
with other line
Normally they open it up in excel, let it do auto-formatting, then save it out again corrupting the data... that happens to me more often than not :)
Bio
Bio
I cannit substract ' ' - 72
You ought to call up your customer and ask them what to do in that case.
@Bio are you using .split(';') here instead of csv.reader with ; as the delimiter??
@JonClements that wouldn't matter? (In terms of how empty columns are handled.)
14:26
so change the empty line to 0 and look for negative numbers in the analysis (if that is considered a valid value or can be used) - if it cannot one needs to ask group providing the data to fix it
Bio
Bio
No
And what do you expect <empty>-72 to be?
There's no "intelligently fill in empty data" function in Pandas or anything. There's no way for it to accurately guess what is supposed to go between the semicolons if not even the programmer knows.
I'm sure something like numpy.loadtxt can do this by setting nans:P
14:27
@davidism Bah... brain burp - ignore me - it's been a long day!
Bio
Bio
Ok I was asking him
now
he tell me to drop the line with the empty values
@Bio that makes it nice and easy then :)
Bio
Bio
Is the a python instruction to do?
Yes
TThe file is tooooo big
There's about 100 ways to load a csv file, and there's about 100 ways to skip lines with invalid data. We can't suggest which of the latter to use because we don't know which of the former you're using
@Bio If your file is too big to load it all into memory then you need to process it line by line.
14:30
@Bio it sounds like you really need to do some searching and read the docs
100
Q: Deleting DataFrame row in Pandas based on column value

TravisVOXI have the following DataFrame... daysago line_race rating rw wrating line_date 2007-03-31 62 11 56 1.000000 56.000000 2007-03-10 83 11 67 1.000000 67.000000 2007-02-10 111 ...

awk -F; '{if($4!="") print $0;}' :P
Bio
Bio
tOk thank you davidism
@Bio sure, but next time please do some research on your own. I literally searched for "pandas remove row".
Bio
Bio
@AndrasDeak Yes this is for linux but not for windows ;)
@AndrasDeak You joke, but I see "how do I call awk/sed/grep/ls/whatever from Python?" questions on the main site every week.
It is a plague on all our houses.
14:34
re-cbg
England   East Midlands               139870
          Eastern                     218418
          London                      214584
          North East                   97853
          North West                  182301
          South East                  303024
          South West                  204938
          West Midlands               189808
          Yorkshire and the Humber    175991
Scotland  Scotland                    190689
Wales     Wales                       119444
Apparently Scotland & Wales aren't worth breaking down into regions sighs
@Kevin who said anything about calling from python?:D
@JonClements they're just going to Scwexit anyway, why bother
What are you up to there, @joncle? There are some standardised divisions of the regions for stats (I'm sure you're aware, though, thinking about it).
@JRichardSnape yeah... got shed loads of lookup tables for all sorts of different stuff - but thanks :)
@AndrasDeak Bash isn't going to like that naked semicolon.
14:39
Gah, I hate the 21st Century. I have managed to log out of my desk phone and cannot log back into it. It should not be possible to log out of a phone. The internet of things has gone too far.
@PM2Ring oops:P
picky little bastard, that bash
My god, this question seems to just be newbie bate. Two different users have left answers that show they completely misunderstand how function/lists work.
Scotland and Wales have, historically been regions, at least as far as Westminster local government was concerned.
@AndrasDeak :) Here's a more condensed version:
awk -F';' '$4{print}'
Already that Q...
> I have a process (class) that I split into several steps (methods)
14:41
Under the system that is, amusingly, entitled NUTS. /civilserviceknowledge
@PM2Ring yeah I'm vaguely aware of all the implicit magic in awk, but I tend not to rely on it:)
well, not all of the implicit magic, but a lot of it
Actually, that's too condensed: it'll also skip numeric zeroes. :)
nobody needs no zeroes in dem data
awk -F';' '$4!=""{print}'
Bio
Bio
I try this : df2[~df2.P_SOUSCR.str.contains(";;")]
but Ive got a problem
14:43
only some days until Corruptlympic games start
@AndrasDeak I'm pretty sure that doing the test in the "pattern" is more efficient than doing it in the "action" (inside the braces). But I could be totally wrong. :D
@PM2Ring no, you're right:)
it's definitely idiomatic that way, even if not more efficient
(Norway Shows Corrupt Olympic Committee the Door)
14:45
@Bio you really do
@Withnail Ah, you know NUTS too (or is that NUTS2?).
that looks like array syntax, I'm guessing pandas dataframe. But you're testing for ';;'? Are your values the entire lines? Or what? If you use pandas, you shouldn't be seeing any semicolons.
Eh, it'll be NUTS '06 or whatever the last one was.
Minor note: that's not a list. — Andras Deak 2 mins ago
It is in fact a Python tuple, but it is still a list of items. :) — larsks 2 mins ago
53k power
If you want to see amazing Bash stuff, check out U&L from time to time. Some of the code there is very impressive. Especially check out Stéphane Chazelas's stuff; he's the guy that discovered (and fixed) the Bash "Shellshock" bug.
14:47
@PM2Ring oh, respect
Huh, Nuts2013 apparently.
Bio
Bio
@AndrasDeak I want to remove all the line that contains ";;"
this means empty values
I have an on-and-off relationship with bash utils; I sometimes try to answer stuff in the tag, then along comes Charles Duffy and tells me why I'm stupid
not his words, obviously:)
Bio
Bio
AttributeError Traceback (most recent call last)
<ipython-input-167-7807560e9683> in <module>()
----> 1 df2[~df2.P_SOUSCR.str.contains(";;")]
2 df2['depassement'] = np.where((df2['P_ACT_KW'] - df2['P_SOUSCR']) < 0), 0, df2['P_ACT_KW'] - df2['P_SOUSCR']

C:\Users\Demonstrator\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
2666 if (name in self._internal_names_set or name in self._metadata or
2667 name in self._accessors):
this the error message that ive got
"Sir, I must ak you to step back"
14:49
And he's a really nice guy. One time he edited an answer of mine so that it'd cope with some obscure corner case (it might've been filenames containing newlines, or to make it compatible with more shells, I can't remember). And then he upvoted my answer. :)
grrrrrrr annoying version dependency catpoop yammin poop face McAnnoying bum head
@dog_rates, all hail pipsy
DM YOUR DOGS, WE WILL RATE (due to a stupid amount of messages only the best will be featured) | IG & SC: WeRateDogs Business: [email protected]
2.2k tweets, 300k followers, following 1 users
I find it hard to believe what pandas doesn't handle empty fields
Wales     CF    21313
          CH     3975
          GL        2
          HR      225
          LD     1984
          LL    17601
          NP    10138
          SA    18264
          SY     3990
That'll do for the mo'
@JonClements have you been rated yet?
14:50
@davidism I was... but was banned from it after I broke the scale... (won't say in which direction though...)
you can even set your own strings that it will recognize as nan..........
missed a pikachu, my build failed because of a silly vagrant version hiccup and I feel a migraine coming on. A yammin' Thursday indeed
"This is Jon. On the Internet, everyone knows he's a dog. 11/10 ninja af."
@davidism oh that's a wonderful <twitter user object>:D
I just wrote a non-Pandas answer to a Pandas question. But the OP is really new to Python and I'm afraid my code might be a bit too advanced for the OP: it's a recursive combinations generator. They didn't post any Python, just some rather clunky SQL, so it's not exactly a "gimme teh codez" question... stackoverflow.com/questions/38636460/…
14:54
my parser broke on that title
Here's another picture without a dog in it. Idk why you guys keep sending these. 4/10 just because that's a neat rug https://t.co/mOmnL19Wsl
Cabbage
@AndrasDeak Yeah. He doesn't want a Cartesian product.
Also what has this chat turned into

« first day (2112 days earlier)      last day (3061 days later) »