Pandas study notes, dataframe sorting problems

Source: Internet
Author: User

Data sources see the front of a few essays

Sort one of the columns

Data.high.sort_values (ascending=False) data.high.sort_values (Ascending=True) data['  High ']. Sort_values (ascending=False) data['high'].sort_values (ascending=true)
p = data.high.sort_values ()
Print (P)
Date2015-01-05    11.392015-01-06    11.662015-01-09    11.712015-01-08    11.922015-01-07    11.99Name:high, Dtype:float64

You can see that a series is returned

We can also sort the entire dataframe

t = data.sort_values (['High ' "Low'],ascending=  True)print(t)

Priority by high sort, high with same, sort by lower

Open High Close low volume Price_change P_change date 2015-01-05 11.16 11.39 11.26 10.89 46383.57 0.14 1.26 2015-01-06 11.13 11.66 11.61 11.03 59199.9  3 0.35 3.11 2015-01-09 11.68 11.71 11.23 11.19 44851.56-0.44-3.77 2015-01-08 11.70      11.92 11.67 11.64 56845.71-0.25-2.10 2015-01-07 11.58 11.99 11.92 11.48 86681.38 0.31 2.67ma5 ma10 ma20 v_ma5 v_ma10 v_ma20 turnover date 2015-01-05 11.156 11.212 11.370 58648.75 68429.87 100765.24 1.59 2015-01-06 11.182 11.155 11.382 54854.38 63401.05 98686.98 2.03 2015-01-09 11.538 11.363 11.682 58792.43 60665.93 107924.27 1.54 2015-01-08 1 1.516 11.349 11.647 57268.99 61376.00 105823.50 1.95 2015-01-07 11.366 11.251 11.543 55049.74 61628.07 10 3010.58 2.97

Pandas study notes, dataframe sorting problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.