Learning notes | Data Analysis: 1.1 data eval…

2018-10-29 15:30:58来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

| Data Evaluation |

- Use Shift + Enter or Shift + Return to run the upper box so as to make it display the edited text format. 

- Markdown used for text writing, while the other is Code cell used for code writing. 

import csv
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn
%matplotlib inline

 

  # Import/load the data set use the read_csv function of Pandas

Shanghai_data = pd.read_csv('ShanghaiPM20100101_20151231.csv')

 

  # View the basic information of data by means of head, info and describe.

Shanghai_data.head()
Shanghai_data.info()

 

  # Print type of python object

print(type(Shanghai_data['cbwd'][0]))

 

  # Change the space into an underline

Shanghai_data.columns = [c.replace(' ', '_') for c in Shanghai_data.columns]

 

  # Convert the numerical value of 1, 2, 3, 4 to four corresponding seasons (by means of the map method of Pandas):

Shanghai_data['season'] = Shanghai_data['season'].map({1:'Spring', 2:'Summer', 3:'Autumn', 4: 'Winter'})

 

- Check data missing and data type:

  # Print the length of data

print("The number of row in this dataset is ",len(Shanghai_data.index))

 

  # Calculating the number of records in column "PM_Jingan"

print("There number of missing data records in PM_Jingan is: ",len(Shanghai_data.index) - len(Shanghai_data['PM_Jingan'].dropna()))

Note: # “dropna()” function used in the following code can delete missing value in data.

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:InsecureRequestWarning: Unverified HTTPS request is being ma

下一篇:函数