pydicom / deid

best effort anonymization for medical images using python
https://pydicom.github.io/deid/
MIT License
142 stars 44 forks source link

AttributeError: 'IPythonDisplay' object has no attribute 'to_string' #100

Closed Anindya911 closed 5 years ago

Anindya911 commented 5 years ago

Can anyone help me on this please ? I was trying to display the largest vale of a column using nlargest method

vsoch commented 5 years ago

of course! Could you please give me some context so that I could reproduce the error?

Anindya911 commented 5 years ago

I was trying to find the largest value of a column of a dataset and then display it.

display(nobel.nlargest(1, "age"))

this is the line of code i used. nobel is the dataframe name

I am a newbie to this field and trying to learn

vsoch commented 5 years ago

Are you using pandas dataframes (hence the reference to columns?) If you have a column, let's say it's named "age", you should be able to do:

nobel['age'].max()

You shouldn't need to use any sort of display().

vsoch commented 5 years ago

Also, if you are having (general trouble) or questions with python, dataframes, it's probably best to try stack overflow or a Github board relevant to the software you are using. pydicom/deid is a python module for working with dicom datasets, specifically headers.

Anindya911 commented 5 years ago

okay, thanks for the help vsoch. well it was instructed to use display,otherwise i wouldve also opted for max(). Anyway thanks. I will try stack overflow or Github board now onwards

vsoch commented 5 years ago

Interesting! I've never used display, and I'm a big fan of ipython. If you want to show me where the instruction is to do this, I'd be interested to take a look.

And keep it up with your learning! I remember the general wisdom that it takes 10 years to learn a language really well, and these early stages when you are copying pasting a lot of errors into Google, or asking questions, are the harder bits. As long as you don't give up, you will be successful.

Anindya911 commented 5 years ago

I was doing a project on datacamp where i came across this. here is the link to the project

https://projects.datacamp.com/projects/441

And thanks for the advice vsoch, means a lot :-)

MAStarsis commented 4 years ago

Hello! I did the same project on Datacamp, and for some reason, it worked removing display, not using anything. Probably is an error that they have there.

vsoch commented 4 years ago

Awesome! Thanks for sharing - others that find the issue here will know to just leave it out.

vsoch commented 4 years ago

Why is this error related to deid?

amaniBoughanmi commented 4 years ago

I have the same issue on the same Datacamp task, how did you resolve it please ?

aladushka commented 4 years ago

I removed display() as advised by MAStarsis and it worked.

tanyabaramzina commented 4 years ago

Thanx! Had the very same problem with DataCamp task and couldn't figure out what's wrong. Removing display() helped.

ayepremyan commented 4 years ago

Actually, you just need to keep only the first display() and remove the second. I think the aim of this task was to show how the display() function is working, but the question is formulated in somewhat tricky way. I think they wanted the students to repeat the same task as they did in question 2.

surajghimire commented 2 years ago

Found this problem on Datacamp. Sad to see they have such silly errors even after two years.

vsoch commented 2 years ago

It’s also very funny that the issue reported and discussed here has nothing to do with the library at hand!

MarcinKamil84 commented 2 years ago

Like @ayepremyan said: it's not an issue BUT:

display(nobel.nlargest(1, 'age'))
nobel.nsmallest(1, 'age')

all works fine.

However, if you try this:

display(nobel['age'].nlargest(1)
nobel['age'].nsmallest(1)

you will be getting the error message.

kchoward48 commented 2 years ago

Like @ayepremyan said: it's not an issue BUT:

  • if you code
display(nobel.nlargest(1, 'age'))
nobel.nsmallest(1, 'age')

all works fine.

However, if you try this:

display(nobel['age'].nlargest(1)
nobel['age'].nsmallest(1)

you will be getting the error message.

This is correct. I worked on the same project. As for the reason, it is a default behavior in Jupyter Notebook:

'By default, a Jupyter Notebook (which is where you are working right now) will only show the final output in a cell. If you want to show intermediate results, you will have to use the display() function.'

So use the former code snippet in the quoted part of this post.