0 Basics to Mastery: Python Big Data and machine learning pandas-data manipulation

Source: Internet
Author: User
Tags jupyter notebook

Here is still to recommend my own built Python development Learning Group: 483546416, the group is the development of Python, if you are learning Python, small series welcome you to join, everyone is the software Development Party, not regularly share dry goods (only Python software development-related), Including a copy of my own 2018 of the latest Python advanced materials and high-level development tutorials, welcome to the next step and into the small partners who want to dive into python.

And also Big Data Learning Group: 784557197

Practical Practice
Execute the following code on the Jupyter notebook:

import pandas as pddf = pd.DataFrame({‘col1‘:[1,2,3,4],‘col2‘:[444,555,666,444],‘col3‘:[‘abc‘,‘def‘,‘ghi‘,‘xyz‘]})df.head()

Get Unique values

df[‘col2‘].unique()

Get non-unique values

df[‘col2‘].nunique()

Get the number of each value

df[‘col2‘].value_counts()newdf = df[(df[‘col1‘]>2) & (df[‘col2‘]==444)]newdf

Application function

def times2(x):return x*2df[‘col1‘].apply(times2)

df[‘col2‘].apply(lambda x:x*2)

df[‘col3‘].apply(len)

df[‘col1‘].sum()

Permanently delete a column

del df[‘col1‘]df

df = pd.DataFrame({‘col1‘:[1,2,3,4],‘col2‘:[444,555,666,444],‘col3‘:[‘abc‘,‘def‘,‘ghi‘,‘xyz‘]})df.drop(‘col1‘,axis=1,inplace=True)df

0 Basics to Mastery: Python Big Data and machine learning pandas-data manipulation

Related Article

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.