python - AttributeError: 'Series' object has no attribute 'sort_values' -


pyldavis library prepare method has crashed while using pandas library inside.

here code:

    def load_r_model(filename):         open(filename, 'r') j:             data_input = json.load(j)         data = {'topic_term_dists': data_input['phi'],                 'doc_topic_dists': data_input['theta'],                 'doc_lengths': data_input['doc.length'],                 'vocab': data_input['vocab'],                 'term_frequency': data_input['term.frequency']}         return data      movies_model_data = load_r_model('movie_reviews_input.json')     print('topic-term shape:%s' %str(np.array(movies_model_data['topic_term_dists']).shape))     print('doc-topic shape: %s' %str(np.array(movies_model_data['doc_topic_dists']).shape))      movies_vis_data =         pyldavis.prepare(np.array(movies_model_data['topic_term_dists']),                                np.array(movies_model_data['doc_topic_dists']),                                np.array(movies_model_data['doc_lengths']),                                np.array(movies_model_data['vocab']),                                np.array(movies_model_data['term_frequency'])) 

error:

... line 283, in prepare topic_proportion=>(topic_freq/topic_freq.sum()).sort_values(ascending=false) ...

attributeerror: 'series' object has no attribute 'sort_values'

why pandas has no attribute sort_values although updated recent version?

as per documentation. http://pandas.pydata.org/pandas-docs/stable/generated/pandas.dataframe.sort_values.html

'sort_values' new in version 0.17.0. so, please update pandas version.

how check pandas version:

import pandas pd pd.__version__ 

how update pandas.

using conda: conda update pandas

using pip: pip install pandas -u


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -