I have a probleme with reading column , When i want to make calculation , even all things is right, the speling name in script is the same as in my csv file, VS code dont read the coulmn name even its speling 100% correct and send all times Error, please help me
Élément
def classify_return(Investment_Return):
if Investment_Return> good_return_threshold:
return’Good’
else:
return’Not good’
Please, consider if this is pertinent to this forum about Jupyter? If you ran this Python code in a more traditional way, such as in the console or as the content a script you called from the command line for Python run, would it give the same outcome? (If you are new to running Python code, you may not be able to do this exercise in your mind, and should actually step through the exercise.) If so, it isn’t a Jupyter issue and so not pertinent to this forum. You’ll want to seek help in a pertinent location.
Your provided code is unuseable and nearly unreadable.
For pasting code in so it is readable in forums such as this & useable by those you want to help you, you’ll want to learn about ‘block code formatting’ here. (Or see about ‘fenced code blocks’ here. They are both the same thing if you look into the details. They just have slightly different terms used in the two locations.
Sr , Im not beguinner , i run c,c++ since 2018 and all what i want is to get answer not somethings innapropriate like your message , Sr i want answer about coulmn not reading in script or maybe you are not able to help me and in this case let another one get help to me
(Notice the code is formatted to be pasteable.).
This code works fine, as can be observed by clicking here and running it when the session starts. (Or click here if you want it in JupyterLite, which is a nice option when MyBinder-served sessions are being slow to come up.) (Here is the boring static view, but the two links prior are much more useful and I suggest using those primarily.)
In other words, I don’t see your reported issue with the limited code and information provided.
If however, I change the equivalent line you had an issue with to mutual_funds['Return_Classification']= mutual_funds['Z'].apply(classify_return), then I get KeyError: 'Z' because there is no column named Z in my dataframe.
its sems your know well code. And instructed person,
Otherwise . You will help me more if you tell me Whats IS the issue with m’y script, file that i load. Because the name of the column is mentioned correcltly in the script.
Error: python dont detect coulmn with name “Investment_Return”
If you read through everything already written above and follow it, you’d see you’d need to provide more details for anyone to be able to help you.
Did you run mutual_funds.columns before you ran your line mutual_funds[‘Return_Classification’]= mutual_funds[‘Investment_Return’].apply(classify_return)? What was the result?
Is there a column named Investment_Return?
When I run mutual_funds.columns at the equivalent point in my demonstration notebook, I see the following
And thus I am sure there is a column named that before I run, mutual_funds['Return_Classification']= mutual_funds['Investment_Return'].apply(classify_return).
This is still not complete, addressing my last questions, or formatted than anyone can use it. See my examples above and follow them using advice about ‘fenced code blocks’.
Why do I say this is not complete:
Where is good_return_threshold set?
Why do I say it doesn’t address what I asked:
You still didn’t run mutual_funds.columns before you ran your code that isn’t working and provide the result.
I’d also suggest you run len(mutual_funds.columns) and compare that result to what you expect.
If you parsed your CSV file correctly, how many columns do you expect?
It seems to me you either didn’t share the result of mutual_funds.head() well in text or you didn’t parse the CSV correctly. If the latter option is the case then it means there shouldn’t be a green check mark for step 3. That being the case seems likely, since you have after running mutual_funds.head() the following:
|—|—|
Meaning there may only be the Row Indexes and a single column. Hence, there is no column Investment_Return, like the error keeps telling you.
But of course, maybe you just didn’t share the result of mutual_funds.head() well in text?