« first day (4082 days earlier)      last day (1088 days later) » 

06:58
hey guys, is there anyway I can find the index that causes IndexError?
it is not a for loop, it is a vectorized call, so I can not see at which value it errors out
import pandas as pd
i = [0, 1]
df = pd.DataFrame({'a': [1, 2, 1]})
df['b'] = df['a'].map(lambda x: i[x])
ideally I want to know the value of x there in this case its 2
07:40
@Jake I don't know Pandas, but there might be a more efficient way to do that mapping, rather than a vectorized call. But anyway, you can print the indices to see what's the last one before the IndexError. Eg,
.map(lambda x: print(x) or i[x])
That works because print() always returns None, and None or blah evaluates to blah.
In Numpy you can use an array or list (but not a tuple) to create a new array from multiple indices. Eg,
import numpy as np

i = np.array([0, 10, 20])
a = [1, 2, 1, 0]
b = i[a]
print(b)

# Output
[10 20 10  0]
 
4 hours later…
11:46
df['b'] = df['a'].map(dict(enumerate(i)))
df.loc[df['b'].isna(), 'a'].unique()
# array([2])
@Jake it's a little of a kludge as it involves creating a temporary dictionary (although that shouldn't matter if i is reasonably sized) - .map will then use that dictionary and you'll end up with NaNs in b for non matches... but everything else will be the replacement value... then you scan the DF again to get the unique values of what wasn't replaced...
 
2 hours later…
13:55
Hello friends
I'm starting learning python. I'm in debian linux.
I've downloaded Anaconda.sh from anaconda repository.
Thank you for helping. :)
But i see in debian, downloading and installing from random sites may break the installation. I see alot of tutorials installing are unaware of that. So if you guys know how can i install anaconda , without having to install in root rather install in home, so that it will not conflict official debian python package and dont go against "dont break debian" philosophy
Thank you for helping. :)
I've used Anaconda a little, but only on Windows. I wish you luck :-)
(not sarcasm)
oh i see anaconda we can configure where it install ,while installing it, without using sudo.
but i'm also unaware, what it does do to my other file system and root file system.
If the documentation doesn't specifically say it make changes to your root file system, then I expect it doesn't make changes.
yes thanks i see it tells to use default location not using /usr and things.
:)
 
3 hours later…
17:28
this suddenly popped up and is a bit annoying already
OPs never reply to comments like that anyway, so we were mostly doing it for the thrill of dunking on others
@12944qwerty That's been around for years
Yeah... but the text it shows says assume they haven't... but most of the time (from what I've seen) people have, they just don't bother putting it in their question for whatever reason.
Wow, i just saw that for the first time...
If the question requires an "attempt", ask for an [mre].
oh yeah... why did i forget about that
17:37
@roganjosh Not sure whether you heard it yet, but "2.16.0 did not protect from uncontrolled recursion from self-referential lookups", either.
@MisterMiyagi I have :'(
Although our scanning regime went ahead and actually, it looks like we're not going to be deluged with vulnerabilities (I'm crossing my fingers that something else doesn't come up). It'd be awesome if we're just detached from this morphing threat entirely, which it seems we mostly are in the Data Science dept.
Perhaps this is the time to add a log4j vulnerability to your code, so that you can document that it was found and fixed afterwards...
I kinda expected to find more JAR wrappers in odd places than I actually have. When I started in DS, everything seemed to suggest there was a war between Python and Java, so I'd assumed more stuff would have been wrapped. Thankfully not
@MisterMiyagi We have one instance in a purely DS-centric library that I found here, so we're documenting that (although it was V1 so actually not vulnerable in itself), and just checking off our customer repos
Praise be to numpy for winning the Java/Python war and making sure we don't have a huge attack surface.... on this one, at least :)
That said; I don't know what's going on with the Engineering dept. handling all these changing fixes. Are you still in red-alert mode, @MisterMiyagi? It's been such a drain on my time even when we're getting back negative dependency tests, so you have my sympathies if you have to keep doing update cycles!
I found another DB of affected services that you've probably seen. I did have a little smile about the irony of Splunk being affected on multiple services!
18:14
I only noticed/or had forgotten that @davidism is a Fellow of the PSF... just saying
I have been summoned. I was nominated and accepted July 2020, was not expecting it :-) twitter.com/ThePSF/status/1288245605551218688
yamming well deserved though :)
Update on my browser session issue: The addon I used turned out to not save my sessions automatically, which... pretty much defeats the whole purpose of it? No clue how people find that useful in its current state. So I figured I'd disable it and let Firefox save my sessions, but now for some reason it only saves the last open window instead of all of them?! I am... vexed
Every quarter there's always a new fellow that I think "how were they not already one?"
Hey folks. Is there any way to implement a step function in Python?
I've looked at the np.heaviside method, but it doesn't exactly meet my needs.
18:23
Although that has been slowing down, which probably means I need to follow more active Python people.
Or it means I'm not meeting them at conferences since they're not in person, gotta change that at PyCon US 2022.
@rb3652 What exactly are your needs?
@Aran-Fey I think I just figured it out. Well, that was short.
@davidism yeah... it's odd... I have a "managing member" membership... but that's not a fellowship... it's almost tempting to run for one of the non-exec director positions but there's no so many other better people out there
I was a contributing member before that, they should really advertise more that maintainers and meetup organizers can get that easily.
@davidism paws crossed that 2022 allows that
18:27
Hopefully it doesn't change, but as of now, it's happening in person April 27 - May 3 in Salt Lake City, Utah.
They're requiring proof of full vaccination and masks at all times.
Yeah, this old pup has had both his normal jabs and getting his "booster" just after xmas
I got booster+flu on Thursday, just made me feel tired on Friday but no other side effects.
@roganjosh I'm in the comfortable position of having 100% absolutely no Java code in my responsibility. There are some non-vital dependency services that I cannot use right now, and the screams from The Pit Below make me sorry for my colleagues, but mostly I can hunker down and wait it out.
yeah... that's supposed to be how it works - I think the first one I felt a little wonky (but not for long) and the second was more a - arhghgghghgh my arm feels stiff
It's the long-term fallout that is going to hit me: We'll be changing our security and FW setup, but those were vaguely planned anyways.
18:34
Similarly, it looks like we'll have big process changes off the back of this, even if we aren't vulnerable. Can't wait for all the bookkeeping!
18:45
Hey all! I have a doubt regarding a pandas question
Is it mandatory for pandas index values to be unique? I feel that's incorrect.
and what is hashable?
Value hashing is something you could easily look up yourself, no? Have you looked at how dictionary keys work?
According to https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html, "indexarray-like or Index (1d)

Values must be **hashable** and have the same length as data. Non-unique index values are allowed. Will default to RangeIndex (0, 1, 2, …, n) if not provided. If data is dict-like and index is None, then the keys in the data are used as the index. If the index is not None, the resulting Series is reindexed with the index values."
@roganjosh yup.. I checked and found this nice answer stackoverflow.com/a/44880799
@RandomPerson but, unique is not mentioned..
"Non-unique index values are allowed" until you rely on that. It'll complain on things like pivot tables, for example
@roganjosh so, the question's answer is incorrect right?
Also, you've given no context for this question. What's the quality of this test? Perhaps they're referring to a very old version that didn't support non-unique keys? I can find references to that in the release notes.
18:52
Why does that make it incorrect?
Also, why are you asking us, why not ask the person who asked you to take this test?
Ah, sorry, yes, the answer is not correct
@davidism the book is a new edition. So, it's mostly a new version of pandas.
What book? How do you know what version of Pandas?
@davidism it's a book containing MCQs related to topics in my school textbook (like pandas, matplotlib)
18:54
OK, so ask your teacher about it.
@davidism it's python3
That doesn't mean anything.
@davidism well, it's a vacation. so I am not able to contact the teacher.
@roganjosh because index can be non-unique
@roganjosh thanks for the confirmation!
Stop using the reply button on every message, it's really annoying to get constant pings during an active conversation. Just type.
19:05
What does "unique" mean in this context? Just wondering
two or more rows/columns should not be having same row/column label
What happens if they do have the same row/column label?
import pandas as pd
a= pd.Series([69,70], index=[1,1])
print(a)
1    69
1    70
dtype: int64
user17242583
Yeah, certainly index (and column, for that matter) values don't have to be unique at all.
user17242583
19:14
It can be tricky if you want to deal with the rows individually then though
I'll rephrase my question. Why is uniqueness recommended? What bad things happen if you don't have uniqueness?
user17242583
I actually asked a question about merging such together
user17242583
@RandomPerson yeah, you can use iloc to access them ad-hoc, but doing other stuff with them, like merging as in my question, can be a pain when they're arbitrary.
Kevin, I have no idea..
@richardec oh.. ok.
user17242583
19:18
Hey @RandomPerson, you're not so random, are you? I thought I saw you on mse before...but maybe that was a different random person.
share the question link. I will let you know if it's me
are ix and reindex equivalent? I don't think so.
Is the explanation in the pic incorrect?
It's not much of an explanation to begin with
Q: what is the color of the sky?
Answer: blue
Explanation: blue is the color of the sky
user17242583
@RandomPerson I recently was looking at this answer
Kevin, I agree. the book which I have is terrible.
@richardec Yeah. I am the OP of the question.
I am the Random Person from MSE
Anyway, SE/SO has shifted from Jira
user17242583
Ah, ok!
user17242583
19:24
Yep, I found this answer the day it was posted.
8k rep within 2 months.. cool!
user17242583
Oh, and you're the OP there too. :)
@richardec haha.. yeah
BTW, .ix is deprecated apparently. That explains why I couldn't find it in the stable documentation
user17242583
@RandomPerson haha, thank you, yes, it's because of the tag (which brought me to your convo) :)
19:26
yup. It was removed in Pandas 1.0.0
@richardec wow! that's nice!
I think the correct answer is A..
According to https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html,
"Returns

DataFrame or TextParser

A comma-separated values (csv) file is returned as two-dimensional data structure with labeled axes."
It would be nice if the explanation actually said what the author thinks the right answer is
19:39
"Gotcha! It returns a DataFrame, not a Dataframe"
Case-sensitivity. So none of the options is correct. Thank you!
I was only half serious. Based on the other screenshots, I doubt that the author has enough attention to detail to even ensure that their own capitalization is correct. I think they simply don't know what they're talking about.
user17242583
19:57
@RandomPerson you're right, it's A.
user17242583
Am I understanding that image? The book is saying pd.read_csv returns nothing/none of the above??
@richardec I guess none refers to none of the above options.
user17242583
So he thinks it reads a csv file into an existing dataframe?
IDK. the book is waste. I regret buying it.
I am unable to find anything named df.from_items
20:03
Hi all, quick question.
i = input("fn: ")  # enter function once

def refractiveProfile(y):
    return eval(i, {'x': x, 'np': numpy})

print(f(42))
@richardec aah! deprecated..
^ The above work returns the value of an arbitrary user-inputted function at x=42
But when I replace x with y, the program fails:
user17242583
Whats f, @rb3652?
@richardec Well, this is embarrassing.
It works now.
user17242583
:D
user17242583
20:06
What was the issue?
Replace f with refractiveProfile. Face-palm moment.
user17242583
haha!
user17242583
Well, I've always said that when you show your code to someone with more skills than the one who wrote it, it gets scared and behaves. And indeed, it seems to be the case!
@richardec So.. option C is correct right?
Option (A) 0 should be the correct answer right?
Let's say we are creating an empty Series, we don't need any arguments.
user17242583
Right
user17242583
20:12
pd.Series() works just fine.
user17242583
@RandomPerson you're actually in good company here
user17242583
I bet you don't know who davidism is.
user17242583
20:31
Hi @SorousH! :)
@richardec Hi :)
It's the first time I join these rooms. I need to explore this environment :d
user17242583
No problem! Go right ahead... ;)
Is this the only Python room here?
user17242583
20:50
Yes, pretty much, @SorousH. There are a few other Python-related rooms, but they are for specific contexts
21:13
Hi, I'm new here in this chat. Nice to meet you all!
Can I ask questions here regarding a pyhton coding?
Dont ask to ask :)
@ShadowEspada dontasktoask.com

« first day (4082 days earlier)      last day (1088 days later) »