数据科学 python

by Zhen Liu

刘震

首先:数据预处理 (Up first: data preprocessing)

Do you feel frustrated by breaking your data analytics flow when searching for syntax? Why do you still not remember it after looking up it for the third time?? It’s because you haven’t practiced it enough to build muscle memory for it yet.

搜索语法时,您是否因中断数据分析流程而感到沮丧? 为什么第三遍查询后仍不记得呢? 这是因为您尚未练习足够的肌肉记忆。

Now, imagine that when you are coding, the Python syntax and functions just fly out from your fingertips following your analytical thoughts. How great is that! This tutorial is to help you get there.

现在,想象一下,当您进行编码时,Python语法和函数会按照您的分析思路从您的指尖飞出。 那太好了! 本教程是为了帮助您到达那里。

I recommend practicing this script every morning for 10 mins, and repeating it for a week. It’s like doing a few small crunches a day — not for your abs, but for your data science muscles. Gradually, you’ll notice the improvement in data analytics programming efficiency after this repeat training.

我建议每天早上练习此脚本10分钟,然后重复一周。 这就像一天做几次小动作-不是为了您的腹肌,而是为了您的数据科学力量。 经过反复的培训,您会逐渐发现数据分析编程效率的提高。

To begin with my ‘data science workout’, in this tutorial we’ll practice the most common syntax for data preprocessing as a warm-up session ;)

首先,从我的“数据科学锻炼”开始,在本教程中,我们将作为预热课程练习数据预处理的最常用语法;)

Contents:
0 . Read, View and Save data1 . Table’s Dimension and Data Types2 . Basic Column Manipulation3 . Null Values: View, Delete and Impute4 . Data Deduplication

0.读取,查看和保存数据 (0. Read, View and Save data)

First, load the libraries for our exercise:

首先,为我们的练习加载库:

Now we’ll read data from my GitHub repository. I downloaded the data from Zillow.

现在,我们将从GitHub存储库中读取数据。 我从Zillow下载了数据。

And the results look like this:

结果看起来像这样:

Saving a file is dataframe.to_csv(). If you don’t want the index number to be saved, use dataframe.to_csv( index = False ).

保存文件为dataframe.to_csv()。 如果您不希望保存索引号,请使用dataframe.to_csv(index = False)。

1。 表的维度和数据类型 (1 . Table’s Dimension and Data Types)

1.1尺寸 (1.1 Dimension)

How many rows and columns in this data?

此数据中有多少行和几列?

1.2数据类型 (1.2 Data Types)

What are the data types of your data, and how many columns are numeric?

数据的数据类型是什么,数字有多少列?

Output of the first few columns’ data types:

前几列的数据类型的输出:

If you want to be more specific about your data, use select_dtypes() to include or exclude a data type. Question: if I only want to look at 2018’s data, how do I get that?

如果要更具体地说明数据,请使用select_dtypes()包括或排除数据类型。 问题:如果我只想看一下2018年的数据,那我怎么得到呢?

2.基本列操作 (2. Basic Column Manipulation)

2.1按列子集数据 (2.1 Subset data by columns)

Select columns by data types:

按数据类型选择列:

For example, if you only want float and integer columns:

例如,如果只需要浮点数和整数列:

Select and drop columns by names:

按名称选择和删除列:

2.2重命名列 (2.2 Rename Columns)

How do I rename the columns if I don’t like them? For example, change ‘State’ to ‘state_’; ‘City’ to ‘city_’:

如果我不喜欢这些列,该如何重命名它们? 例如,将“状态”更改为“ state_”; 从“城市”到“ city_”:

3.空值:查看,删除和插入 (3. Null Values: View, Delete and Impute)

3.1多少行和列具有空值? (3.1 How many rows and columns have null values?)

The outputs of isnull.any() versus isnull.sum():

isnull.any()与isnull.sum()的输出:

Select data that isn’t null in one column, for example, ‘Metro’ isn’t null.

选择在一列中不为空的数据,例如,“ Metro”不为空。

3.2为一组固定的列选择不为空的行 (3.2 Select rows that are not null for a fixed set of columns)

Select a subset of data that doesn’t have null after 2000:

选择2000年后不为空的数据子集:

If you want to select the data in July, you need to find the columns containing ‘-07’. To see if a string contains a substring, you can use substring in string, and it’ll output true or false.

如果要选择7月的数据,则需要查找包含“ -07”的列。 要查看字符串是否包含子字符串,可以在字符串中使用子字符串,它会输出true或false。

3.3空值子集行 (3.3 Subset Rows by Null Values)

Select rows where we want to have at least 50 non-NA values, but don’t need to be specific about the columns:

选择我们希望至少具有50个非NA值但不需要具体说明列的行:

3.4丢失和归类缺失值 (3.4 Drop and Impute Missing Values)

Fill NA or impute NA:

填写NA或估算NA:

Use your own condition to fill using the where function:

使用您自己的条件使用where函数填充:

4.重复数据删除 (4. Data Deduplication)

We need to make sure there’s no duplicated rows before we aggregate data or join them.

在聚合数据或将它们联接之前,我们需要确保没有重复的行。

We want to see whether there are any duplicated cities/regions. We need to decide what unique ID (city, region) we want to use in the analysis.

我们想看看是否有重复的城市/地区。 我们需要确定要在分析中使用的唯一ID(城市,地区)。

删除重复的值。 (Drop Duplicated values.)

The ‘CountyName’ and ‘SizeRank’ combination is unique already. So we just use the columns to demonstrate the syntax of drop_duplicated.

“ CountyName”和“ SizeRank”组合已经是唯一的。 因此,我们仅使用列来演示drop_duplicated的语法。

That’s it for the first part of my series on building muscle memory for data science in Python. The full script can be found here.

这就是我在Python中为数据科学构建肌肉内存的系列文章的第一部分。 完整的脚本可以在这里找到。

Stay tuned! My next tutorial will show you how to ‘curl the data science muscles’ for slicing and dicing data.

敬请关注! 我的下一个教程将向您展示如何“卷曲数据科学的力量”来对数据进行切片和切块。

Follow me and give me a few claps if you find this helpful :)

跟随我,如果您觉得有帮助,请给我一些鼓掌:)

While you are working on Python, maybe you’ll be interested in my previous article:

在使用Python时,也许您会对我以前的文章感兴趣:

Learn Spark for Big Data Analytics in 15 mins!I guarantee you that this short tutorial will save you a TON of time from reading the long documentations. Ready to…towardsdatascience.com

15分钟之内即可学习Spark for Big Data Analytics! 我向您保证,这个简短的教程将为您节省阅读冗长文档的时间。 准备去…朝向datascience.com

翻译自: https://www.freecodecamp.org/news/how-to-build-up-your-muscle-memory-for-data-science-with-python-5960df1c930e/

数据科学 python

数据科学 python_如何使用Python为数据科学建立肌肉记忆相关推荐

  1. python实现数据可视化_使用Matplotib python实现数据可视化

    python实现数据可视化 I Feel: 我觉得: In today's digital world data has become as important as air. Machines &a ...

  2. 利用python数据可视化_想用Python做数据可视化?先迈过这个“坎”

    文丨Chris Moffitt 编译丨姜瑞琪 触脉咨询数据分析师 用过python的人都会面临一个问题,尤其是初学者:我应该选哪个来实现数据可视化? 面对众多的选项,要弄清楚什么时候使用哪个的问题没那 ...

  3. python怎么整理数据的_如何用 Python 整理数据?

    文章转载自公众号  林骥 , 作者 林骥 0. 序言 整理的意思,是整顿使之有条理,目标是让零散杂乱的数据变得井然有序. 许多分析数据的时间. 做数据分析工作,表面是在制作数据报表.提交分析报告,背后 ...

  4. python怎么存数据_五种使用python储存数据的方式

    原标题:五种使用python储存数据的方式 在python编程开发中,总是不可避免的遇到数据储存的问题,下面小卓就介绍python与几种数据储存方式交互的方法. json文件 json是一种轻量级的数 ...

  5. python数据数据存储-五种使用python储存数据的方式

    原标题:五种使用python储存数据的方式 在python编程开发中,总是不可避免的遇到数据储存的问题,下面小卓就介绍python与几种数据储存方式交互的方法. json文件 json是一种轻量级的数 ...

  6. python四维数据可视化_如何使用python进行数据可视化?

    使用包matplotlib包 导入语句: import matplotlib.pyplot as plt 散点图 折线图 帮助: 颜色线型点 一张画板绘制多张图 添加文本: 找到配置文件: 如何使用p ...

  7. python怎么重新开始_人人都是数据科学家从新开始用Python学习数据科学的完整教程P3...

    上周一P2篇大家熟悉一些有用的库来学习Python.P3篇让我们学习如何用Pandas在Python中进行探索型数据分析. 为了进一步探索我们的数据,让我向您介绍另一种动物(好像Python还不够!) ...

  8. 大智慧数据文件python_马克的Python学习笔记#模块和包 3

    让目录或者zip文件成为可以运行的脚本 我们的程序已经从一个简单的脚本进化为一个涉及多个文件的应用.我们希望能有某种简单的方式来让用户运行这个程序 如果应用程序已经进化为由多个文件组成的"庞 ...

  9. wind金融数据接口python_从wind python接口获取数据并存储

    转载的别人的资料,yuzhucu@CSDN # -*- coding:utf-8 -*- ####################################################### ...

最新文章

  1. SpringBoot如何处理java内存溢出
  2. 数据结构之二叉搜索树(BST)
  3. .net反编译软件简绍
  4. 设计模式 -- (14)中介者模式
  5. 基于JAVA+SpringMVC+Mybatis+MYSQL的心理咨询预约系统
  6. AT SELECTION-SCREEN
  7. Tomcat内存溢出,解决方法
  8. UOS系统JAVA应用在任务栏显示类名的问题跟踪调用
  9. MySQL的ALTER命令
  10. 打印excel html js,前端js打印(导出)excel表格的方法实例
  11. 性格测试软件帖子,九张图片测试你的性格(转载)
  12. 10. 微型计算机常用的显示器有哪几类及其工作原理,四川自考07311《多媒体技术》全真模拟试题(十)...
  13. 使用stata临床决策曲线进行外部模型验证
  14. 微博营销,究竟该怎么做?(实战系列一:粉丝篇)
  15. secret学习笔记
  16. 设置海思芯片MMZ内存、OS内存详解
  17. 5 python数据分析基础——批量进行数据分析(一)
  18. 亮点回顾!Go 11岁生快!
  19. jjjjjsssss
  20. Qt Creator删除toolbar中多余的“分隔符”

热门文章

  1. 隐藏导航条HTML,jQuery实现的导航条切换可显示隐藏
  2. css知识笔记(二)——盒子模型
  3. 1G.小a的排列(C++)
  4. 2018.10.24 NOIP模拟 小 C 的序列(链表+数论)
  5. 《精通Spring4.X企业应用开发实战》读后感第二章
  6. getBoundingClientRect说明
  7. Java Timestamp Memo
  8. Appium——主从控制执行
  9. 脱壳_详细_使用的方法_01
  10. How to connect oracle databse