« first day (3746 days earlier)      last day (1421 days later) » 

00:10
Cbg
How can I just get from a 2D array in a text file, a specific element like file[i][j]?
just like that?
What you mean?
Take the array, access value.
But can I just directly access the element, just returning it?
@Marco What are you really trying to ask?
00:20
I just want to load a especific element, I don't want to waste memory loading the line/entire 2D array to do it, just iterate over the file to get the element that I want.
@Marco so it seems you know exactly what you have to do
Iterate just like a NumPy 2D array?
Iterate what like a numpy 2d array?
The 2D array in the file
I'd think you want to iterate the file... but that has very little similarity to numpy arrays unless you mean "using a loop"
@Marco uh, you know what, I think I'll just skip these from now on
00:29
Yes, using a loop
00:46
hello, i provided some sensitive data in my question and would like my question to be removed, but I can't since my question has answers. Is it possible to negotiate a deletion of my question or altering it?
@zzzzz raise a custom moderator flag on your post explaining the situation
mods can redact sensitive data without a trace, not normally possible by user edits or deletion
01:04
@AndrasDeak Just to you know, no, I don't know how to do what I asked, if I knew I wouldn't ask here.
@AndrasDeak If you just don't want to help, just ignore it and don't respond, why would you argue with the person who needs help? What does it cost to send a tutorial to the person, if you find it so easy?
@AndrasDeak I believe I don't have to ask you for permission to ask the question again, so I'll ask the question again.
How can I just get from a 2D array in a text file, a specific element like file[i][j]?
I just want to load a especific element, I don't want to waste memory loading the line/entire 2D array to do it, just iterate over the file to get the element that I want.
 
3 hours later…
04:43
so uh, I made something that seems to work but, when i make it into a function, and then use return instead of print() to print the result...let me first post the code to give the idea of what i mean
import sys

string = sys.argv[1]
def position():
        for index in range(len(string)):
                if string[index] == 'A':
                        print(int(index+1))

position()
this works
BUT, if i replace the print in the function with a return, then the index+1 won't evaluate correctly and give me the right result
I use this with a test string like "ABBBCCDD"
it should give the position for each matched A like in the loop in numbers, but since the range function start at zero, i found that incrementing it in the loop worked better for me
I tried using index += 1 but it didn't evaluate either for some reason??
didn't give me any error, just printed only a single 1 instead of the usual output i'd get
think this could be a simple fix but I've been wracking my brain about this for a couple minutes now hmm
05:13
can't edit my last message, but the correct string i tried the above code on was actually "AAABBCCD", though any other input always gave me "1" when not using print() like i already explained :)
 
1 hour later…
06:22
nvm, already found the way on SO
07:04
Boy, it sure has been a while since I last saw someone solve their problem on their own. I almost forgot that was possible
3
 
3 hours later…
09:42
@NordineLotfi 1. Why are you applying the int function to index+1, which is already an integer? No need. 2. Why are you iterating over indexes rather than the characters in the string? 3. If you create an iterator on the string you can access its next item anywhere with the next function.
10:19
@Marco FWIW, I did not get your question either and would need the exact same clarifications. Files do not contain arrays, they contain bytes; if and how that content maps to your array is 100% needed to know in order to say how to access it.
11:06
@holdenweb 1. I did this initially because when i was using print(index+1) it was throwing an error, and using just index += 1 or index + 1 wasn't working somehow. 2. I didn't thought i could do this :O 3. I see!
I just hope of the day when i don't need help or wait hours to fix my own problem :D

I'm aware I'm probably asking a lots of things these days, but i guess it's what it is
Take a look at the enumerate function, it comes in handy often
for index, char in enumerate(string, 1):
    if char == 'A':
        print(index)
^ much more pythonic
But more importantly, stop using global variables as input for functions. If a function needs an input, that's what we have function parameters for
@Aran-Fey I used it twice but didn't manage to make as much as you did here :O
@Aran-Fey this is nice and much simpler than mine yeah
@Aran-Fey right, can i use the excuse of "it was just to do prototyping"? :D
Asalam aleykum everybody :)
nope, I don't buy that :P
11:24
@Aran-Fey at least i tried :)
 
1 hour later…
12:34
Hi guys, could anyone help me with the procedures if I wanted to make a repo which is like a music downloader(means its not supposed to be used for wrong purposes or redistribution of music, right?). Which repo license would be nice for it? And can you help me with points to be included in the disclaimer part?
13:21
@NordineLotfi You're learning. Just don't lean too much on external help, or you'll never lose the dependency!
The more you learn, the more of your own problems you can solve.
@CoolCloud Why do you need a disclaimer? Most open source licenses disclaim all warranties and explicitly eschew guarantees for any purpose. Python can be used for "bad things" but its license contains no usage restrictions. Nobody is ever going to hold Python legally responsible for bad things people might do with it.
@holdenweb Oh so there will be no harm to me too? or is it just python whose privillaged?
Putting any kind of disclaimer, or placing obligations on your users as to purpose of use, would seem to me to be inviting involvement as a third party in legal suits. Python has no special privileges in this regard.
@holdenweb yes but youtube-dl
13:33
Something like this seems fine?
This project is for educational purposes only. I will not be held responsible for the misuse of this package, or any violation of Deezers Terms of use.
@CoolCloud is there content on deezer you can download legally?
@AndrasDeak Seems pretty fired up.
Youtube-dl's escape was all the user content on youtube
@AndrasDeak Hmmmmm, totally unsure :p
I suppose no.
I'm not a lawyer though
13:39
:p There are plenty of libraries out there too. I hope it wont be much of an issue.
14:04
hi anyone needs help in Python ?
@CoolCloud
"The Recordings on the Deezer Free Service are digital files protected by national and international copyright and related rights. They may only therefore be listened to within a private or family setting. Any use for a non-private purpose will render the Deezer Free User liable to civil and/or criminal proceedings. Any other use of the Recordings is strictly forbidden and more particularly any download or attempt to download, any transfer or attempt to transfer whether permanently or temporarily onto the hard drive of a computer or any other device (music players in particular), any rippin
So, you cannot download any content with any license that will indemnify you, if I read that correctly
@roganjosh Oh, but there are alot of other libraries too right? That has downloads from youtube and so on, none the less pydeezer. So are those illegal too?
Quite possibly they are. I'm also not a lawyer. You can also see that shoplifting is unambiguously illegal but it doesn't mean that people don't do it; so it's a straw man argument that other such libraries exist. My point is that the core purpose of your library goes against that contract so I don't suppose it makes a difference what license you distribute your software under
Okay thanks, I've decided to drop the project :)
14:34
Hello python heroes !
Hi! I was wondering what do you use for documenting a python project? I would like to create something outstanding for a project that has a web scraper, a data cleaner, and a web app. I had a look on Internets and the first thing that come up was Sphinx but I wonder if it is still a used tool?
unfortunately it is. Let me know if you find a better one
Do not hesitate to @ping me :p
@Aran-Fey Ahahaha Is it hard to handle ^^?
Yeah. The ReST syntax is horrible, and lots of things I care about can't be customized
And despite all the features ReST has, there's still no way to highlight function parameters. People usually just make them italic. The whole thing really grinds my gears
Damn, I'm already scared ...
15:23
Hi everyone! Just thinking, could you help me with this question? stackoverflow.com/questions/65751881/…
Hello. Did you read the documentation that I linked you to?
I read it but can't find out how it helped
When you join your tables, both tables contain columns with the same name; you need to provide an lsuffix and an rsuffix parameter so that they can get unique names after the join
l and r refer to "left" and "right" tables that you're joining, respectively
do you mean the 'df' variables?
The df columns, yes
15:29
I'm a little confused by what you mean - df columns or df variables?
What do you consider to be "df variables"?
If both tables contain the column called data and you try to join them on some other column (let's call it transaction_id), then what should appear in the data column after they've been joined? Now you have two sets of values with the same name (data)
you know the varibles I defined in the for loop?
I don't understand what 'tables' you are talking about
DataFrames, then
That probably is my fault; I'm thinking in the context of SQL sorry, but the principle is the same. So substitute "table" for "DataFrame" in my previous comments sorry
15:34
ok
I just learned python I don't even knew the language 'SQL' existed
Don't get distracted by SQL, that was my bad for mentioning it
uh, sorry, to waste your time or something but could you explain all that you said in the comments?
and the column thing
import pandas as pd

df1 = pd.DataFrame({'transaction_id': [0, 1, 2],
                    'data': ['a', 'b', 'c']})
df2 = pd.DataFrame({'transaction_id': [0, 1, 2],
                    'data': ['d', 'e', 'f']})

# THIS FAILS
#df1.join(df2, on='transaction_id')

# THIS WORKS
df1 = df1.join(df2, on=['transaction_id'], rsuffix='_added')
print(df1.head())
A reverse MCVE. Now I've seen everything
9
Surprise!
I did VTC their question but didn't downvote it. I don't think there's much use in commenting on something to be Roomba'd but that should be enough to keep them going
15:44
wait - I didn't really do anything with the join() function!
Oh? What's this in the traceback, then?
File "C:/Users/code/pycharm_coding/stock_investing_using_AI/stock investing/do
now/scripts/finance_5_&_6.py", line 72, in compile_data
    main_df = main_df.join(df, how='outer')
oof forgot that
Lesson learned; make sure you read your tracebacks! Python doesn't just dump that text out for fun :)
thanks
so could you post how to solve my case?
I don't think we can answer that because we don't know how you want to handle this. Now that you understand the problem, how do you want to deal with it?
15:51
No, because the question is closed (so cannot accept answers) and it doesn't merit reopening when the issue is buried in a traceback. I think I've given you enough to fix it now
Actually, it's not true that it's just buried in the traceback. I just skimmed the question and took your surprise as it not being in the initial code... but it is. There isn't anything more to add, though, really, to what I've said
so you just mean I have to add a lsuffix and rsuffix right?
Will that make the error go away? Yes. Will it produce the output you want? Who knows
That's what I've been saying. Though my example is slightly disingenuous because you need to set transaction_id as the index column of the right DataFrame for it to work fairly (it's convenient that the ids start at 0 in both cases, which happens to match the DataFrame index column). This is the fairer fix to the problem:
import pandas as pd

df1 = pd.DataFrame({'transaction_id': [2, 3, 5],
                    'data': ['a', 'b', 'c']})
df2 = pd.DataFrame({'transaction_id': [2, 3, 4],
                    'data': ['d', 'e', 'f']})
df2.set_index('transaction_id', inplace=True)

# THIS FAILS
#df1.join(df2, on='transaction_id')

# THIS WORKS
df1 = df1.join(df2, on=['transaction_id'], rsuffix='_added')
print(df1.head())
Notice that transaction_id == 5 doesn't exist in df2, so you'll get NaN values in the joined data there
16:23
Uh, doenst work-I put None but the error still came :(
I'm pretty convinced my example does work. I don't know where None comes into this but you'll need an MCVE. As per the room rules please post such an example off-site and link back here (since I expect it will be somewhat longer than my examples). Notice how my code blocks have been copy-paste into your editor and can run (provided you have the libraries)? Please make sure you give something like that
Wait, are you suggesting that you put None as the input to lsuffix or rsuffix?
Hey guys just curious what sssort of projects might I expect from a practical challange
16:45
yeah that
And, given everything I've said on this matter, why would you expect that to work?
hi guys
@python_coder I've explained (and demonstrated!) why you need to provide some way for the columns to be uniquely identifiable after the join. I don't know how else I can explain or illustrate it to you. My last example gives you a test-bed to see why it works, and also test what the how parameter ('inner', 'outer', 'left', 'right') works. I think it's up to you now to do some research
@AkbarNasiri hello
cbg all, can I give a bounty to an answer but accept a different answer for my question?
16:58
thanks
ok I am a bit confused, I have got 3 answers and each answer offers something the others dont
the actual answer to my question would be all three combined
@python_user relevant?
it sure is, thanks I will see what best course I can take
17:16
ended up giving bounty to a detailed answer and accepted a solution that does what I specifically asked for
sounds reasonable
17:48
[[3], [3, 3], [7, 2, 1], [7, 2, 4, 4], [6, 9, 2, 1, 8]]
if you have a triangle encoded like that, i wnat to find the max path sum from root to a left
why does this hit max recursion depth?
@Trajan what is num_lines?
that would be the same as the length of matrix =
[[3], [3, 3], [7, 2, 1], [7, 2, 4, 4], [6, 9, 2, 1, 8]]
len(matrix) = 5
And is it actually the same?
Because it seems to me that you keep increasing level with each recursion level, so eventually you'd have to hit level == num_lines. Or is num_lines more than 1000?
It's also weird to me that from (index, level) you go to (index, level + 1) and (index + 1, level + 1), so it seems to me that you can't hit index > level. But that's just from a superficial glance, I haven't tried figuring out what's going on.
@AndrasDeak you are a genius for some reason it was different
thanks a lot
18:13
recbg
@Trajan or what if Andras isn't genius :P
Sssh...
18:33
@holdenweb Thanks, appreciate the advice/motivation :D!
19:18
not a reusable resource. stackoverflow.com/questions/53462727/… The OP doesn't even need the column 'previous'
@smci that doesn't seem like a valid close reason
@AndrasDeak It used to be, on SO. Either way, it's not a real question. The solution is simply using df['current'][:-1].
19:43
I disagree. It seems like a perfectly ok question with an answer to me. There's 5 bajillion crap questions flowing in on the main feed than to be going after that
@roganjosh Creating unnecessary dicts to solve non-problems. Whatevs. I'm looking at some of the other bajillion too. Give me strength.
@smci just step away from main :P I can only take very short doses at the best of times these days
20:07
@roganjosh or should I say Give me teh strengthz...
Alas, I'm not the person to help on this one. If u hve ne gud phyton, it's stolen. I've transitioned to the meme, which oddly works quite well with the "yam" substitute; "Behold! The field in which I grow my yams. Lay thine eyes upon it and see that it is barren"

« first day (3746 days earlier)      last day (1421 days later) »