python 加载CSV \检查cat功能\显示NaN \显示摘要数据的数量

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 加载CSV \检查cat功能\显示NaN \显示摘要数据的数量相关的知识,希望对你有一定的参考价值。

# save filepath to variable for easier access
melbourne_file_path = 'melb_data.csv'
# read the data and store data in DataFrame titled melbourne_data
melbourne_data = pd.read_csv(melbourne_file_path) 
#Check if you have categorical features, object means categorical
print("---Check if you have categorical features, object means categorical---","\n")
print (melbourne_data.dtypes.sample(melbourne_data.shape[1]),"\n")
# DataFrame with NaNs
melbourne_data_with_nans = melbourne_data
# How many NaNs
print("---How many NaNs---","\n")
print(melbourne_data.isnull().sum(),"\n")
# drop NaN
melbourne_data = melbourne_data.dropna()
# print a summary of the data in Melbourne data
print("---Summary of the data---","\n")
print(melbourne_data.describe(),"\n")
#list of all columns in the dataset
print("---List of all columns in the dataset---","\n")
print(melbourne_data.columns)
# the head command returns the top few lines of data.
print("---Prints the top few lines of data---","\n")
print(melbourne_price_data.head())
# Well know question is is there any NaN value and length of this data so lets look at info.
print("---Well know question is is there any NaN value and length of this data so lets look at info---","\n")
print(melbourne_price_data.info())

以上是关于python 加载CSV \检查cat功能\显示NaN \显示摘要数据的数量的主要内容,如果未能解决你的问题,请参考以下文章

linux命令morelessheadtail

linux命令morelessheadtail

Linux 命令中 morelessheadtail 命令的用法

python数据分析之:数据加载,存储与文件格式

将数组写入csv python(一列)

Linux 操作命令 more