Pandas (python) data processing: only the DataFrame data of a certain column is normalized.

Source: Internet
Author: User

Pandas (python) data processing: only the DataFrame data of a certain column is normalized.

Pandas is used to process data, but it has never been learned. I do not know whether a method call is directly normalized for a column. I figured it out myself. It seems quite troublesome.

After reading the Array Using Pandas, you want to normalize the 'monthlyincome 'column. All the online chestnuts are normalized for the entire dataframe, because some of my data columns are of a category and cannot be used:

Import pandas as pdimport numpy as np # load data # cvsdf = pd. read_csv ("train1.csv") # normalized s = (df ['monthlyincome ']-df ['monthlyincome']. min ()/(df ['monthlyincome ']. max ()-df ['monthlyincome ']. min () # Delete safely. If del is used to permanently delete df2 = df. drop (['monthlyincome '], axis = 1) # Insert the normalized column to the array. In the first 14, I inserted it to 15liedf2. insert (14, 'monthlyincome ', s)
Print (df2.columns [13: 15])


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: 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.