0

I retrieved a csv file from the IMDB database. I imported this file with titles = pd.DataFrame.from_csv('titles.csv', index_col=None).
I have tried many sort/order commands on my ipython notebook, but all of them are throwing errors.

NameError Traceback (most recent call last)
<ipython-input-49-bb0d78f2f73d> in <module>()
----> 1 sort(titles[titles.title== 'Hamlet'])

NameError: name 'sort' is not defined

I tried the following to sort the year series in my dataframe, consisting of year and title.

order(titles$title) 
sort(titles[titles.title== 'Hamlet'])
titles['year'].sort()
titles['year].order()
order(titles.year)
titles.sort('year')
titles.order('year')
Mr. T
  • 11,960
  • 10
  • 32
  • 54
arunv
  • 13
  • 5
  • 1
    Need `titles['year'].sort_values()` – jezrael Feb 11 '18 at 10:38
  • 1
    Welcome to StackOverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Feb 11 '18 at 10:38
  • It works but gives me only values of 'year' , need 'title' values too. – arunv Feb 11 '18 at 11:08
  • 1
    need `titles.sort_values('year')` – jezrael Feb 11 '18 at 11:09
  • Thanks jezrael , this works. How do we use order() ? – arunv Feb 11 '18 at 11:18
  • Order is too old, [link](http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#changes-to-sorting-api), not used yet. – jezrael Feb 11 '18 at 11:20

0 Answers0