« first day (3554 days earlier)      last day (1377 days later) » 

2:23 AM
stackoverflow.com/q/62806327/1426065 too broad/gimme teh codez/library recommendation
 
 
4 hours later…
6:51 AM
I import a function "kreisfläche" from an existed python file1 in new python file2 with:

```from Aufgabe_10_1 import kreisfläche```

The problem is: In the new file2 python imports not only the function Kreisfläche. It import and executes also the other print commands from the file 1
Could some please explain me why python does import the whole commands of file 1 and not only the function which actually I need?
 
7:05 AM
when you import a name (that could be a function, a list, a string, class definition...) from a file, two things will happen. 1) python checks in sys.modules if that file was imported already. If no, it executes the file so that all function definitions, class definitions, variable declarations etc exist, and stores a reference to the file in sys.modules. If it was already imported, nothing is done. 2) the name that you specified is looked up in the imported file.
the thing that you didn't know was probably that the whole file needs to be executed in order for python to be able to do anything like importing with it
it can't pick and choose to only run the section that you are interested in, it's either the whole file or nothing. Which is why script-code like print statements are usually gated off through a special section that will explicitly not be run during imports.
 
7:36 AM
Thanks that much for your detailed explication. That means I have to avoid using a print statements in a file which I want to import later. And I need just to write the Functions witout calling them in this file. The call will be done later in the new file, where the functions need to be called. In this way the stored reference value in sys.module will not have a big size in the computer's RAM. Did I understand it well?
 
on point, except for the last part with the RAM - the size is not important.
 
cabbage
Guys when I create a file in python , why does it take the code to stop execution to create the file?
I mean , what if I want to create a file and use the same file in the program
 
7:53 AM
@AhmyOhlin You can call your functions in the same file, you just have to do it inside a if __name__ == '__main__': guard
@Anarach MCVE?
 
@Anarach Can you clarify what you mean "the code to stop execution to create the file"?
 
Closed
 
8:59 AM
New record: 540 lines of monkeypatch code to make sphinx do what I want
 
@Aran-Fey yeah , that was a stupid question , sorry for the bother.
 
9:34 AM
Can you guys tell me a bit about the use of item pipelines and items in scrapy? I don't understand what's the use of these modules.
Are items the same as dictionaries? If that's true, why should we use them anyway?
 
:O Ubuntu in Windows has turned against me. Now I'm getting a permission error on something that worked fine a few months ago. I didn't realise it would be updating itself
<wipes brow> Remembered my root password on the 4th attempt, to sudo my way out of that mess like a Windows pro
A few chmod 777s will help when I have time to revisit the issue :P
 
user12867493
9:55 AM
I want to modify a Python module I installed on Mac. How can I do so?
 
import the_module; print(the_module.__file__), then open it in your favorite text editor
 
 
1 hour later…
11:26 AM
Hi folks :)
I have encountered a strange dataframe
this is what it looks like in a notebook:
I would think lemmatized is a column name but that seems to be wrong:
so is lemmatized the first row? doesn't seems so:
 
it's the .index... - so freqdf_onlylemmatized.index...
 
@JonClements oh ok! thanks!
so it is the name of index "column", it seems
 
if you want the index as a column then you can do a .reset_index() on your df to get the index as a column and a new RangeIndex
 
@JonClements Thats pretty cool! (It seem to have worked, just tried it now...)
 
 
4 hours later…
3:42 PM
guys I don't know the proper words to reference this question, and this is why I couldn't find info on google, but it's a simple one I suppose: if I have a function A that calls function C, and a function B which does the same, can a variable in function C hold the information of which function called func C? Thanks
 
Do you have pseudocode?
I'm also tempted to extrapolate to Flask, since that's what you were working with last. In which case, you could add the data to the session
 
something like that
 
Obligatory question: Why do you want to do this?
 
I could include a parameter in func C of course, but I wonder if there's another manner
 
@PedroSpinola Please have a look at the code formatting guide. It links to a sandbox if you want to test formatting.
 
3:51 PM
sorry I thought that only worked on SO questions
I wanted to learn if maybe there was an attribute for a variable inside a function that would tell if the mother function was called by another function, or something in this line
 
@PedroSpinola No, it's specifically tailored to the chat rooms
 
the reason I thought of this is to make a debug function for my algorithm
 
Please re-post after reading the guide. You can also practice in the sandbox linked there
 
The inspect module gives you full access to the call stack.
 
re-post?
"call stack", awesome, thanks!
 
3:54 PM
@PedroSpinola Notice that I moved your unformatted post
 
The Python VM also supports various hooks, most importantly trace hook and audit hook.
 
alright but should I repost it even though my question was already answered?
 
Note that hooks are generally more portable than stack inspection.
 
@PedroSpinola probably no reason, now
 
formatting is awesome :D
 
user13415013
4:04 PM
guys , could you give idea to get string from list of classes and function.
 
str(the_list)
 
user13415013
Actually, I have a tuple of classes which is as (<function torch.nn.functional.elu>,
 <function torch.nn.functional.relu>,
 <function torch.nn.functional.selu>,
 <function torch.nn.functional.selu>,
 <function torch.nn.functional.selu>)
 
str(the_tuple)
 
user13415013
It does changes but i have problem in extracting the function names from them.
I had used str([item]).split(' ')[1] in loop for extracting functions, but i have some classes that dont work in this logic
 
user13415013
Like for methods, it produces undesireable result
method			<built-in method sigmoid of type object at 0x7fc412ba0340>
method			<built-in method tanh of type object at 0x7fc412ba0340>
 
4:08 PM
what result do you desire?
 
To extract the name of a single function, str(the_tuple[1])
No point using split to turn the string back into a list, when you had a list (or tuple) in the first place.
 
user13415013
@MisterMiyagi , I want to extract name of the func,
 
user13415013
@Kevin ,what can i apply to extract only name of that method or func
 
user13415013
Thanks for your idea . :)
 
@nerd as in, "sigmoid"? Or "type.sigmoid"?
 
4:11 PM
If you're saying "what? I can apply [that code you just posted] to extract only the name of one method or function?", yes, that's what the code I just posted does
If you're saying "What code can I use to extract only the name of one method or function", the code I just posted does that
 
user13415013
@MisterMiyagi for sigmoid, <built-in method sigmoid of type object at 0x7fc412ba0340>
 
Consider zip.__name__. Is that what you are looking for?
@nerd But you just listed that as "undesireable result".
 
>>> my_funcs = (abs, id, dir)
>>> str(my_funcs[1])
'<built-in function id>'
 
user13415013
@MisterMiyagi Thanks func.__name__ gives the function name , Problem solved.
 
user13415013
Thanks @Kevin, appreciate :)
 
4:20 PM
@nerd those seem like functions, not classes. What do you need the names for? I'm only asking because you might have, say, a lambda in there.
 
Oh yeah, I forgot to give my lecture: unless you're writing your own debugger, you almost never need to know the name of a function.
 
user13415013
@AndrasDeak , all of them were function, some like torch.sigmoid, torch.tanh was method function
 
Maaaybe it's useful if you're writing a descriptor decorator and need something fancier than wraps
 
user13415013
@Kevin , oh sorry, i was just experimenting things about neural network, not on debugging.
 
As far as I know, no part of a neural network needs a string containing a function name to work
 
user13415013
4:30 PM
@kevin i should then save that content into zip and try to get from zipfile .
 
If you're talking about my comment on this post, yeah, that's basically what I'm proposing
 
user13415013
oh thanks, I had used same .content to extract, i will see if it works in future.
 
user13415013
I was making csv file to gather information about activations and things that impact on neural network .
 
I'm a little surprised that zipfile doesn't have a way to operate on a bytes instead of a file. I guess it's not too hard to write the data to disk or create a StringIO, but I'm rankled by the lack of symmetry between zipfile and gzip, the latter of which can operate on bytes
 
user13415013
oh
 
4:35 PM
@nerd So you're trying to write diagnostic information to a csv that compares the relative performance of various functions? Ok, that counts as "debugging" in my book. If you want human-understandable function names, that's a valid use-case
In my personal projects I don't bother with such niceties, but then again, I don't have to worry about my output being comprehensible to anyone but me
 
user13415013
oh, yes it is debugging.
 
user13415013
@Kevin , Projects are killing me. Do you give me your thoughts on how to get job in deep learning.
 
user13415013
I have moderate or more exprience with deep learning but not personal project.
 
what is "a job in deep learning"?
 
user13415013
like deep learning engineer or ml engineer
 
4:40 PM
^ those are buzzwords which managers make up which can mean anything - to be more clear: what do you want a job doing?
 
user13415013
In machine learning or data science .
 
user13415013
Although i have finished dl specialization , but as begineer, there is little nervous, what can i do now.
 
I don't have experience with applying for machine learning jobs, but I'll regurgitate some advice I've heard before. Apply for machine learning jobs even if you don't meet the listed requirements; sometimes you'll get interviewed anyway. (Obviously don't lie and say you have 10 years of ML experience if the job listing says "10 years ML experience required".)
 
fyi: I mean literally anything - I've worked as a "data scientist" and "data engineer" where my jobs ranged from being a DBA to just backend to full analytic work to building front-end dashboards (so don't get caught up on the titles just look at the job description - and confirm it in the interview.....advice I wish I had given past me)
 
user13415013
oh thanks @Kevin . I will go on truth.
 
user13415013
4:46 PM
@LinkBerest so what projects did you have done in first job as data scientist. Any thoughts for me .
 
Job requirements are often written by people who have no contact with the team's day-to-day operation. You might get to the job interview and say "the listing said I need to know both Java and JavaScript, but I only know Java", and the interviewer will reply "... We don't use JavaScript here. Cathy in HR must be adding buzzwords to our listings again."
 
@nerd serialize input, change bad pdfs into computer usable jsons (or csvs), data munging and wrangling <- times that by 20, more data cleaning, a lot of basic probability and statistics
 
I was sent one in the last couple of days where python was a requirement and pandas was "desireable"
 
^^ above is "my first data scientist jobs"
basically, you will never get good data files (there are no good csvs, jsons, etc) so most of my first jobs were getting people to either use Excel correctly, stop using it at all, or just cleaning up all their human readable - computer horrible - csvs (and pdfs/text which they were using "positional logic" to read which broke all the time) so I could actually calculate something
 
user13415013
:D , So do i in future
 
4:52 PM
if you can show you know data flows and stuff like data warehouses or Amazon's products in your resume - this would be very desirable for most position I know of (though half of those are not ready to use big data systems because no infrastructure)
^ actually above is why I am a "data engineer" now (also because I like building the architecture more than the dashboards)
 
user13415013
:D, Thankyou for your thoughts @LinkBerest .
 
Also, I'm just gonna point out that when I worked at Tesco, the Data Science department was split in half; half worked with machine learning, the other half was focused on optimisation problems. My title was still "Data Scientist" but it had nothing to do with neural networks or deep learning. And actually, we had some pretty big wins
 
To my earlier comment: Deep Learning is actually really useful but you don't want to just say it for everything or you look like a handyman who only carries a hammer. You need to know the limitation of that technique and when/where it should be applied
@roganjosh we don't split ours (we just switch around to keep some variety/meet SCRUM requirements our manager has) but similar concept with what I do now
 
user13415013
Thats means, is there no hope for AGI and things. I was always motivated by we need to go deeper.
 
user13415013
Anyway, See you later guys, Have a good day.
 
5:03 PM
@LinkBerest how does that even work? We're talking tasks that they budget 1yr+ to complete. A rotation would be a bit wonky there, no?
Kinda like the game where you fold up paper, draw a small portion of a person and then pass it on
 
@roganjosh it doesn't, yes, we basically just switch to whichever team we're comfortable with and ignore what "it says on paper" mostly
Problem is the standard: "We use this with other programming project and don't understand why the data team would be different" (even though half don't even identify as programmers)
 
Ah. Sounds wonderful :)
 
5:18 PM
Jun 8 '16 at 2:24, by JGreenwell
words I said to someone this week: "Machine learning, yes I'm using that term instead of Artificial Intelligence to make a point, is not magical nor does it truly reflect the thinking methods of humans. It is instead more of a form of math and logic which helps machines recognized patterns."
^ remembering that Artificial Intelligence is a cartoon model we use to explain concepts to people unfamiliar with them also helps. If we move to AIG it won't be with what we currently call "deep learning".... though it may be with something that comes from understanding and figuring out how to overcome its limitations
 
5:32 PM
Contributing in Main can be so discouraging sometimes... I can relate whoever said they had felt that state years ago... :/
 
@anky huh? if that's in response to my chat post - I didn't say that to someone on SO (it was to a junior data....I think analyst.... I was mentoring at the time)
 
@LinkBerest ehh.. ? Not at all :) I was just sharing something I have felt over the past days of being an irregular (In Main of course)
 
We're all irregulars here
 
ah, carry on then :)
 
@roganjosh ^^ edited..
 
5:37 PM
Oh, well then you don't belong :P
 
Bangs my head on the false walls - realizes this materialistic view isn't worth.... Then realizes this wall is not worth enough too :P
 
The wall is not real
 
haha good catch ;)
@roganjosh I felt that too ... awww....:(
:P
vote for vote is going to take me out soon and CTRL+V with sone editing
 
now banging your head against a true wall - now that hurts
 
@anky ?
 
5:42 PM
but not all true walls are real walls
 
@LinkBerest That's why you need to be part of the First Earth Batallion
 
@roganjosh Sadly yes, new contributors are focussing on just the reps not the quality of answer even if it means editing max() with first() for exmple, sadly some old contributors are playing a part too..
@LinkBerest yeah they are apparently true walls may be :D
 
Eh, I've abandoned the pandas tag. We've always have our Jezza answering dupes but it's become unmanageable
 
I know this because true wall is real wall returns false sometimes
 
@roganjosh well yeah thats a different story altogether, and I have fought a lot and flagging has failed so..........
@LinkBerest of course 'true wall'=='real wall' is False
 
5:47 PM
I wish I had some rousing words. I don't. Rest, my friend. The battle is over
 
replying is rousing now ;)
i didnt mean anything else though :P
 
@roganjosh I was part of Second Battalion! but it all changed after the fall
^ I'm 90% sure Kevin has a story about this somewhere
 
Did you walk through walls and carry baby lambs onto the battlefield?
 
I see you are an RO now? while True : I am glad .. :)
 
goats! 2nd battalion had no use for 1st's lambs
@anky flagging still works (somewhat) downvotes is what seems most failed to me (or just too much upvoting without actually reading/understanding what you are upvoting)
downvoting an answer that invites SQL injection and seeing it has +6/-2 vote count
and 12 thanks to add to the confusion
 
5:52 PM
Lol, I was just talking about the Pandas tag. Don't take this to SQL territory, I don't think I can handle it
@anky I'm glad that you're glad :)
 
@roganjosh :)
@LinkBerest in pandas tag you may feel the opposite
@LinkBerest I am assuming ~25% doesnt know injection
 
My estimates put it closer to 90%
At least the questions that also include
 
:D okay then, higher the better
or worse -er
 
worser. Definitely worser
 
yes i meant the other way round actually
however i wish to say Congratulations and well deserved on RO, well suited.
 
5:59 PM
@anky Thanks :) It happened in March btw :)
 
yeah, pandas over sqlalchemy - I'll take pandas (sqlalchemy is full of these comments)
Oh please, no. Why are you encouraging string concatenation to build SQL queries? This just propagates the issue of SQL Injection, whether or not it's directly relevant with this dataset — roganjosh Jun 1 at 22:02
 
@roganjosh an example of what we discussed the other day
@roganjosh I didn't realize I was so irregular :/ that's not forgivable
 
@LinkBerest yey, I get to re-live my trauma :P
 
My comment is on the question itself you just beat me to the answer :P
 
@LinkBerest was this a debate b/w f strings and cursor.execute ?
 
6:04 PM
I don't downvote questions with SQLInjection (you don't know, that's part of the point in asking a question) - but answers..... oy vey
 
okay I can see now (courtesy the link)
 
@anky sure it is. Don't worry about it :)
 
I like f strings /me ducks
 
I have seen you solve OS (windows) problems though @LinkBerest thanks for contributing and nice to meet you
 
/me realizes Andras is not around right now and puts away his shield
 
6:10 PM
@LinkBerest lol :D he is a Diamond (me realizes now)
 
Bah, humbug!
 
heh, I also think they get over-used if that makes you feel better Andras :) ;)
 
I don't mind f-strings. I do mind pointless f-strings.
 
but the "f" stands for fun so we should use them everywhere - its more fun!
 
Can't argue with that
 
6:17 PM
no importa though :) Ellos continúan with gracia
 
@anky I believe we met when I was using a different name or my older account itself but either way: nice to meet you too :)
 
tried my best @AndrasDeak pardon me if wrong
@LinkBerest what was that..?
 
@anky I wasn't talking to you so we're good
 
Classic
 
the post I linked to is still listed under my old handle (before name change) and the one before that I don't bring up (I didn't hang out in Python back then either so not likely anyone here would know it)
 
6:21 PM
okay makes sense :)
the world can't be all receptive : Live with that anky
rbrb for a while
 
rbrb anky
 
:)
 
 
4 hours later…
11:01 PM
Hi
I am using pandas data fram to compare a string value
But it throws 'ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().'
The code is 'if(df['A'].str.contains('AB')):
df_['ET'] = df['S']
 
OK, and you'll have googled that error, right?
 
Can anyone help me what am I doing wrong here ?
Yes
 
What did you find?
 
It asks to populate with fillna(0)
I've written that line too above this
 
I'm not sure that your searches would give that result
 
11:05 PM
Hmmm
 
I dare say that this is the most-common warning with pandas
 
Do you mean refer to this post ? stackoverflow.com/questions/36921951/…
Oh okay
 
Ignore my previous comments
 
Basically what i want is to create a new data frame if that column value matches the expected string
Okay I'll ignore your previous comments
 
You're mixing if with something that can be vectorised
 
11:09 PM
Vectorised ? Not really. The column values that I'm interested are string
 
Ok, but you can still use the same syntax
 
Yes, what the pseudocode for the code snippet I wrote was create a new data frame with two columns
Then fill the new data frame with zeros
Then if block to check with old data frame[column].str.contains('Intersted Value'):
 
I don't want pseudocode. There is no reason to not post a representative example here
 
Okay
But the error is being thrown with if condition
 
Seriously?
 
11:13 PM
After df['A'].str.contains('AB') you have a column full of True and False values. What do you expect the output of if column_full_of_booleans: to be? Is a column full of booleans true or false?
 
You're mixing vectorised pandas operations with general python syntax
 
column_full_of_strings which corresponds to that column
Ah okay
 
I have to go sleep and regenerate. You need to give an MCVE @YatShan
 
Okay
May I know what is MCVE?
 
input + desired output + explanation
 
11:31 PM
Okay I'll prepare and share
 
@LinkBerest I don't imagine front end validation to be much utility other than user assisting.
 
Old Data Frame
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8
1 abc def ghi jkl mno pqr stu
2 abc1 def1 ghi jkl mno1 stuv stu
3 abc2 def2 ghi jkl mno2 abc stu
4 abc3 def3 ghi jkl mno wxy stu
5 abc4 def4 ghi jkl mno1 zyq stu
6 abc5 def5 ghi jkl mno4 qpad stu

New Data Frame
Column1 Column2
pqr stuv
wxy zyq
@Aran-Fey Above is input and desired output. Explanation is based on based on Column6 values, Column7 values are populated into two columns in new data frame
 

« first day (3554 days earlier)      last day (1377 days later) »