« first day (3290 days earlier)      last day (1883 days later) » 

05:28
This one's especially for @MisterMiyagi and Andras. Here's yet another garbled new-user question How to skip Column title row in Pandas DataFrame which needs editing and retitling; the only thing that's clear is that what the user really wants to do isn't literally "skip the column title row", but something else... possibly something like "suppress header row from being displayed" or...
... "suppress header row from beign written to_csv". The point is the OP isn't at all clear, and given this question's likely to be closed imminently for one of several other reasons. Whereas in the past I would have attempted to ask the OP what they actually needed to do (which they probably don't know and can't articulate), and/or to retitle the question accordingly. Now I can't see the point in making that effort, knowing I'll at best get no thanks and at worst criticized without reason....
...so what does @MisterMiyagi say should be done with its title and/or text? (regardless that it gets closed, as it's about to be)? I'm waiting for actual suggestions this time.
(and yes Andras I know this one's about pandas and very few here are interested. That's not the point I'm asking.)
Simultaneously, other user believes it is a dupe, hence:
And another:
And I edited a draft of that dupe target into the SO canon: sopython.com/canon/134/…
for @MisterMiyagi: note the very heavy surgery I had to perform on the question, title, body, tags to get it coherent and reusable.
@AndrasDeak The above is two more recurrences. So I added it to the SO canon. Did not file pandas docbug yet still.
06:46
Unrelated:
Is this one beyond redemption Cutting a string into groups of n? The OP is unclear, but I thought there were some existing similar questions.
07:09
4 hours later: "(removed)". Intrigue-ometer is off the scale
 
2 hours later…
08:44
@roganjosh you're not missing much unless you find "anyone there?" intriguing :)
09:02
@JonClements I thank you for not taking every opportunity to exploit that situation of me not knowing :)
I might have missed out the second sentence that said something like: "I heard roganjosh never gets around to feeding the puppy sausage rolls... I think he should" or something like that :p
Ix-nay on the ausage-say
@JonClements good job that libellous statement was removed, then! :P
Now that intrigue is gone, I guess I'll turn to No Such Thing as a Fish and do some cleaning. Life in the fast lane. Rbrb for a while
09:14
Sounds good... (except the cleaning bit...)
09:51
where am i going wrong here friends ?
/
#Python program to remove all the duplicates.
number_list=[2, 3, 7, 0, 9, 2, 5, 0, 4, 3, 1, 77, 65, 2, 4]

new_number_list=[]
for item1 in number_list:
for item2 in new_number_list:
if item1!=item2:
new_numbers_list.append(item1)

print(new_number_list)

/
if item1!=item2: <- if you find any item that's different from the current one, you append it to the result
you want to check if all items are different from the current one
I really should stop giving away the answers to these kinds of questions... people need to learn how to debug
@Aran-Fey Doesn't it check all items in a new_number_list with a particular item in the original list ? I have tried quite a lot but i am getting output as just [].
ah, you're right. I overlooked something there.
So you know the append is never called. You just need to figure out why. Step through the code with a debugger or add some print statements to see what's happening
or find your favorite rubber duck and explain the code to it. That might give you some insight, too.
@Aran-Fey :)
Try writing out what happens on paper. Pretend you're the interpreter.
It should take 3 iterations at most to find the problem
10:03
@AndrasDeak Okay. Sure
3 iterations of which loop though?
...actually, it doesn't matter (hint, hint)
10:37
I wonder what they were really after here - they've accepted an answer but still can't work out why they'd want to follow that approach
I'm surprised the answerer included that if not k.startswith('__') check. That makes it work as expected in methods that call super(). Wonder if they really thought of that
Who knows? :)
10:53
Definitely a strange thing to need though. My best guess is that OP needs to create a lot of dicts with specific keys to send to some API, and that's the most convenient way to do it
Could be I guess...
11:07
They should probably just use **kwargs...
user10984358
how can I pass in username and password to a webpage if my end objective is to download links in the page using urllib.request.urlretrieve(url, path)?
user10984358
what is something I must be looking at?
You generally send a post request to get a session cookie and then re-use that cookie in later requests...
user10984358
I can use selenium and once I am logged in I can get links but is there a way using urlib?
user10984358
@JonClements I will look into this, thanks!
11:11
Open your browser's dev tools, log in, find the corresponding HTTP request, then make the same request with urllib, store the session cookie you get, and send that cookie along with all future requests
do yourself a favour and drop urllib for requesting stuff... and use requests instead... it's far less tortuous and feature rich
user10984358
first time trying stuff with cookies lets see how soon I can get this setup, ok, dropping urillib :)
Use a requests.Session and cookies are handled automagically
Does anyone know the maximum file size for image uploads on SO?
Browse, drag & drop, or paste an image or link
(max 2MB)
oh, it really says that. That's hardly visible with my dark theme
ah, not the dark theme's fault
Whoever writes the CSS for SO has a stupid obsession with specifying sizes in pixels
user10984358
11:29
all it took was two lines using requests, i can now see the links if I do r.text :)
user10984358
s = requests.Session()
s.auth = ('username', 'password')
r=s.get(url)
Isn't that so much nicer than urllib :)
user10984358
heck yeah, though looking into cookies would make me look like a "hacker" :D
Huh. Do lots of websites implement HTTP basic auth? I never even considered the possiblity of that being in use at all
def fun1(a,b):
	x=10
	print('hai')
	print(a+b)
	def fun2():
		x=x+1
		print('hello')
		print(a,b)
		print(x)
	print('python')
	print(x)
	fun2()
	print(x)
	fun2()
	print(x)

fun1(3,4)
this is showing something weird for me
11:39
@Aran-Fey in my experience you can also upload larger but also meta.stackexchange.com/questions/333607/…
i was expecting the output to be : hai,7,hello,10,11,10
user10984358
@Aran-Fey well its a website that provides datasets, the register option in site sends everyone the same predefined guest username and password, so I guess they dont need fancy security?
@AndrasDeak Hmm, I'm uploading a gif - I don't think it tries to compress those
user10984358
UnboundLocalError: local variable 'x' referenced before assignment @Abhinav
what does that mean
11:43
"something weird" <- great description of an error
@Aran-Fey could be, I tried jpg and png
did i phrase incorrectly
@Aran-Fey :(
@Abhinav yes
user10984358
when he does do x=x+1 the scope of x is tied to fun2 and since fun2's x is yet to be defined you get that error, is that what happened?
ohkay
user10984358
11:46
@Abhinav no, I am in the dark as well, that was not an answer
@Abhinav when describing a problem, explain the wrong output or the error message, preferably with a full traceback. See also stackoverflow.com/help/mcve and codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question
okay.will keep in mind
@TheNamesAlc Just curious.What do you refer by scope
user10984358
@Abhinav scope of a variable, in c you stuff like scopes like local, function, global etc like a lifetime of a variable, there are better people here to answer this than me, just dont want to tell something wrong
12:05
@AndrasDeak when you say explain the wrong output,do you mean i should explain why my code is wrong?
@Abhinav no, explain exactly what the wrong behaviour is
If you knew why the code was wrong you wouldn't have to ask :)
The error message in the output shows-Unboundlocalerror:local error 'x' referenced before assignment. I expected the function to take x=10 as the value of variable x in the fun2 and show output as 11 but i think it's not the case here
x is a local variable inside x so why can't it be accesed in fun2 when fun2 is inside fun1
because i have read that functions always create local variable
Umm... I'm probably missing something but for this one - when would np.argsort(c) not give a correct result?
12:32
Do we have a dupe for "what's the difference between a += b and a = a + b"?
nvm, found it
12:44
@JonClements if in v 1 were 5
OP wants to sort v with key zip(v,c)
ahhh okies
13:01
Wow, this answer is straight up copied from here and nobody noticed/cared for 7 years?
13:13
@Aran-Fey doesn't look like copy-paste
though I'm on mobile
If it's clear-cut for a layman, flag it
Yeah you're right, they're not quite as similar as I initially thought
Umm... do we not have a dupe for this ?
13:43
There's something severly wrong with how python prints tracebacks. I just got a RecursionError and the stack trace is just hundreds of these:
Traceback (most recent call last):
  File "/mnt/data/Users/Aran-Fey/Desktop/folder/coding/python/applib/applib/descriptors.py", line 50, in _default_getter
    return vars(obj)[varname]
KeyError: 'base_directory'

During handling of the above exception, another exception occurred:
In other news, I just learned why the AttributeError message only tells you the class of the object and not the actual object itself. Because then you can't get an endless AttributeError -> __repr__ -> AttributeError loop like I just did.
I've quite often seen people do: def __getattr__(self, value): return getattr(self, value) instead of return super()._getattr__(value) or something like that
Thanks for your answers but none is actually helping me your just making a statement without telling me nothing.. how — Aru 6 mins ago
We need to write better homeworks
13:59
Is that person trying to implement itertools.zip_longest...?
The answers there are worse than the question
Yes
Or just zip. "Merge by index" and "factorial" so...
14:51
@JonClements Yeah, that makes the most sense... (assuming we do some modification of value or self, because __getattr__ is the fallback after the dotted lookup fails)
 
1 hour later…
user10984358
16:29
hey guys I need a clarification regarding range, if range is lazy in python3, how can I do indexing and still not run out (exhaust) of values?
user10984358
>>> t=range(10)
>>> t[2]
2
>>> for i in t:i
...
0
1
2
3
4
5
6
7
8
9
range is not an iterator, so it can't be exhausted
user10984358
alright, what makes it possible to index range then?
it implements __getitem__?
user10984358
so when I do t[2] it does two iterations and returns that?
16:31
why would it do any iterations? It just returns self.start + index * self.step
user10984358
got it, thanks!
user10984358
do you know how to search chat history?
there's a search bar in the top right
user10984358
I asked a question 4-5 months back and I need to see the answer people gave me here
user10984358
I never noticed that, so dumb of me, thanks again!
17:03
>>> lols = [[[1, 2], 3, [4, 5], 6], 7]
>>> def flat(lols):
...     for i in lols:
...         if isinstance(i, list):
...             yield from flat(i)
...         else:
...             yield i
...
>>> list(flat(lols))
[1, 2, 3, 4, 5, 6, 7]
My straightforward interpretation is the above generates a frame for each level of recursion, getting to 3 frames deep in the example above, does anyone know this to be right/wrong?
@TheNamesAlc FYI, the "said by" field doesn't expect the name of a user, it needs the user id . Which you can find by selecting a user profile on stack overflow and looking at the url
@TheNamesAlc here's a potentially relevant search: chat.stackoverflow.com/…
17:52
@AndrasDeak ahh... oops. Thank you for setting me straight
 
1 hour later…
18:55
Just spent an hour figuring out why one of my test cases is failing. Turns out that my serializer has no problem serializing pathlib.Paths or pyfakefs.FakePaths, but can't serialize both at the same time. Can't wait to find out what's causing that.
@AndrasDeak closed <flies away again>
I'll hammer it if someone can assure me that the DataFrame constructor accepts a numpy array like that
@Aran-Fey I'm on mobile but check accepted answer. Plus OP asked about "in python"
Thanks
 
2 hours later…
21:11
Try-else must be as obscure as for-else
21:59
@AndrasDeak I would say less obscure, it seems to me that people know try else that don't know for-else.
22:52
Recommendations as well

« first day (3290 days earlier)      last day (1883 days later) »