Pandas value_counts() returns non unique values

江枫思渺然 提交于 2021-02-08 11:33:56

问题


I have a dataframe of surgical activity data that has 58 columns and 200,000 records. One of the columns is treatment specialty. Each row corresponds to a patient encounter. I want to see the relative conribution of medical specialties.One column is 'treatment_specialty'. I have used

df['treatment_specialty'].value_counts(normalize=true)

to get the relative proprtions of each specialty. This below is returned (no errors). The specialties have codes eg 150 is neurosurgery.

df.head()

150    0.642710
150    0.186934
218    0.062673
108    0.048300
218    0.018964

There are 69 records and a lot of the specialties have duplicate entries. Could I have some whitespace in the dataframe or is there another reason why the specialty codes are not unique?

来源:https://stackoverflow.com/questions/60142205/pandas-value-counts-returns-non-unique-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!