Python Basic Data Statistics (II)

Source: Internet
Author: User

1. Convenient data acquisition

1.2 Network data acquisition:

1.2.1 Urllib, Urllib2, Httplib, httplib2 and regular expressions (Python3 in Urllib.request, http.client)

Get AXP stock data for nearly a year

2. Data preparation and collation

3. Data display

4. Data selection

4.1 Select rows

4.1.1 Index

Obj.ix[val

4.1.2 Slices

obj[' xx ': ' xxx ']

4.2 Select columns

obj[' xx ']obj.xx

4.3 rows, Columns-label label (LOC)

in [+]: Djidf.loc[1:5,]out[]:    code                      name Lasttrade1   AXP  American Express Company    76.2002    BA the        Boeing company   159.5303   CAT          Caterpillar Inc.    94.5804  CSCO                    Cisco Corporation    30.1005   CVX       Chevron Corporation 115.600 in   [65]: djidf.loc[:,['code','lasttrade']]out[ []:     code lasttrade0   AAPL   120.0001    AXP    76.2002     BA   159.5303    CAT    94.580 ...   XOM    85.890
obj.loc[x:xx, [' Y ', ' yy ']

4.4 Row and column area-label label (Loc and at)

in [+]: djidf.loc[1:5,['Code','Lasttrade']]out[66]: Code lasttrade1 AXP 76.2002 BA 159.5303 CAT 94.5804 CSCO 30.1005 CVX 115.600In [+]: djidf.loc[1,'Lasttrade']out[67]:'76.200'In [[]: Djidf.at[1,'Lasttrade']out[68]:'76.200'
obj.loc[x, ' y ']

4.5 rows, columns, and regions (Iloc and IAT)

In [djidf.loc[1:5,[]:'Code','Lasttrade']]out[69]: Code lasttrade1 AXP 76.2002 BA 159.5303 CAT 94.5804 CSCO 30.1005 CVX 115.600In []: djidf.iloc[1:6,[0,2]]out[70]: Code lasttrade1 AXP 76.2002 BA 159.5303 CAT 94.5804 CSCO 30.1005 CVX 115.600In [[]: Djidf.loc[1,'Lasttrade']out[71]:'76.200'In ["Djidf.at[1",'Lasttrade']out[72]:'76.200'In [[djidf.iloc[1,2]:]out[73]:'76.200'In [djidf.iat[1,2]:]out[74]:'76.200'
obj.iloc[a:b, [c,d]]

4.5 Item Selection

In [all]: Quotesdf[quotesdf.index >='2016-12-20']out[77]: Open Close High low volume2016-12-20 74.681487 74.741230 75.179363 74.213482 3244900.0...2017-01-20 75.989998 76.199997 76.910004 75.389999 8382000.0In [[quotesdf[]: Quotesdf.index >='2016-12-20') & (Quotesdf.close >=76)]out[78]: Open Close High low volume2017-01-04 75.260002 76.260002 76.550003 75.059998 4635800.0...2017-01-20 75.989998 76.199997 76.910004 75.389999 8382000.0
quotesdf[(quotesdf.index >= ' 2016-12-20 ') & (Quotesdf.close >=76)]

5. Simple statistics and processing

6. Grouping

7. Merge

Python Basic Data Statistics (II)

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.