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

数据科学 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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/393113.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

oracle 管道通信,oracle管道化表函数

转自:http://pengfeng.javaeye.com/blog/260360在我所做过和参与的大多数项目中,都会有用户提出的复杂的一些统计报表之内的功能要求,根据统计的复杂程度、效率及JAVA程序调用的方便性方面考虑,主要总结出以下几种方案: 1、SQL语句 该方案只能实现一些相…

ebtables之BROUTING和PREROUTING的redirect的区别

ebtables和iptables实用工具都使用了Netfilter框架,这是它们一致的一方面,然而对于这两者还真有一些需要联动的地方。很多人不明白ebtales的broute表的redirect和nat表PREROUTING的redirect的区别,其实只要记住两点即可,那就是对于…

LVS的四种模式的实现

LVS 是四层负载均衡,也就是说建立在 OSI 模型的第四层——传输层之上,传输层上有我们熟悉的 TCP/UDP,LVS 支持 TCP/UDP 的负载均衡。LVS 的转发主要通过修改 IP 地址(NAT 模式,分为源地址修改 SNAT 和目标地址修改 DNA…

MyISAM与InnoDB两者之间区别与选择,详细总结,性能对比

1、MyISAM:默认表类型,它是基于传统的ISAM类型,ISAM是Indexed Sequential Access Method (有索引的顺序访问方法) 的缩写,它是存储记录和文件的标准方法。不是事务安全的,而且不支持外键,如果执行大量的sel…

leetcode557. 反转字符串中的单词 III

给定一个字符串,你需要反转字符串中每个单词的字符顺序,同时仍保留空格和单词的初始顺序。 示例: 输入:“Let’s take LeetCode contest” 输出:“s’teL ekat edoCteeL tsetnoc” 代码 class Solution {public St…

linux命令数据盘分多个区,pvmove命令 – 移动物理盘区

pvmove命令的作用是可以将源物理卷上的物理盘区移动到一个或多个其他的目标物理卷。使用pvmove命令时可以指定一个源日志或卷。在这种情况下,只有逻辑卷使用的区才会被移动到目标物理卷上的空闲或指定的区。如果没有指定的物理卷,则使用卷组的默认规则分…

spanning-tree extend system-id

spanning-tree extend system-id 在交换机上启用extended-system ID 特征使其支持 1024 MAC 地址, 在全局模式下使用 spanning-tree extend system-id命令.禁用时前面加 no。 spanning-tree extend system-id no spanning-tree extend system-id 命令用法 在不提供 1024 MAC 地…

leetcode841. 钥匙和房间(bfs)

有 N 个房间,开始时你位于 0 号房间。每个房间有不同的号码:0,1,2,…,N-1,并且房间里可能有一些钥匙能使你进入下一个房间。 在形式上,对于每个房间 i 都有一个钥匙列表 rooms[i]&a…

Codeforces 235C Cyclical Quest (后缀自动机)

题目链接: https://codeforces.com/contest/235/problem/C 题解: 对大串建后缀自动机 对询问串复制拆环。这里一定要注意是复制一个循环节不是复制整个串!循环节是要整除的那种 然后要做的实际上是在大串上跑,每经过一个点求出当前的最长公共子串&#x…

泛型型协变逆变_Java泛型类型简介:协变和逆变

泛型型协变逆变by Fabian Terh由Fabian Terh Java泛型类型简介:协变和逆变 (An introduction to generic types in Java: covariance and contravariance) 种类 (Types) Java is a statically typed language, which means you must first declare a variable and …

安卓系统换成linux系统软件,将旧安卓手机打造成“简易linux”机器,并部署AdGuardHome...

从原教程的安装Linux Deploy 完成后,在配置 Linux下载镜像的一些东西时有些许出入。首先,我是用的下载源地址是 http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports 清华的源挺好用的。 其他有出入的配置如图(记得把源地址改清华的,华中科大…

let与expr命令的用法与实战案例

let命令的用法 格式: let 赋值表达式 【注】let赋值表达式功能等同于:(赋值表达式) 例子:给自变量i加8 12345678[rootXCN ~]# i2 [rootXCN ~]# let ii8 [rootXCN ~]# echo $i 10[rootXCN ~]# ii8 #去掉let定义 [root…

在使用ToolBar + AppBarLayout,实现上划隐藏Toolbar功能,遇到了一个坑。

问题:Android5.0以下版本Toolbar不显示沉浸式状态栏,没有这个问题,但是5.0以上版本,就出现了莫名其妙的阴影问题,很是头疼。 分享一下我的解决方案: 在AppBarLayout中加一个属性: app:elevation…

leetcode1476. 子矩形查询

请你实现一个类 SubrectangleQueries ,它的构造函数的参数是一个 rows x cols 的矩形(这里用整数矩阵表示),并支持以下两种操作: updateSubrectangle(int row1, int col1, int row2, int col2, int newValue) 用 new…

msbuild构建步骤_如何按照以下步骤构建最终的AI聊天机器人

msbuild构建步骤by Paul Pinard保罗皮纳德(Paul Pinard) 如何按照以下步骤构建最终的AI聊天机器人 (How to build the ultimate AI chatbot by following these steps) 快速指南,可帮助您避免常见的陷阱 (A quick guide that helps you avoid common pitfalls) Bui…

第一章:最小可行区块链

概览区块数据结构区块哈希创世块创建区块保存区块链验证区块完整性选择最长链节点间通信操作节点架构运行测试小结概览 区块链的基础概念非常简单, 说白了就是一个维护着一个持续增长的有序数据记录列表的这么一个分布式数据库。在此章节中我们将实现一个简单的玩具版的区块链。…

Oracle Controlfile控制文件中记录的信息片段sections

初学Oracle的朋友肯定对Controlfile控制文件中到底记录了何种的信息记录而感到好奇,实际上我们可以通过一个视图v$controlfile_record_section来了解控制文件的信息片段: SQL> select type, record_size, records_total from v$controlfile_record_s…

linux 怎么禁止遍历目录,linux下遍历目录功能实现

/*编译:dir:dir.cgcc -o $ $<*/#include #include #include #include #include int do_search_dir(char *path);int do_check_dir(char *fullpath, char* truefullpath);void usage(char *apps);int count 0;intmain(int argc,char **argv){char fullpath[…

leetcode面试题 16.26. 计算器(栈)

给定一个包含正整数、加()、减(-)、乘(*)、除(/)的算数表达式(括号除外)&#xff0c;计算其结果。 表达式仅包含非负整数&#xff0c;&#xff0c; - &#xff0c;*&#xff0c;/ 四种运算符和空格 。 整数除法仅保留整数部分。 示例 1: 输入: “32*2” 输出: 7 代码 clas…

团队项目电梯会议视频

http://v.youku.com/v_show/id_XMjcyMjI3Mjk2NA.html?spma2hzp.8244740.userfeed.5!2~5~5~5!3~5~A转载于:https://www.cnblogs.com/jingxiaopu/p/6749776.html