Hi there and welcome to Data Analysis with Pandas. 大家好，欢迎来到《潘达的数据分析》。
So what is pandas? Pandas is a library built on top of the Python programming language. 那么什么是Pandas呢？Pandas是建立在Python编程语言之上的一个库。
Now if you're unfamiliar with Python it's a language developed by Guido van Rossum in 1991. 如果你对Python不熟悉，它是由Guido van Rossum在1991年开发的语言。
So it's a little over a quarter century old. 所以它已经有四分之一世纪的历史了。
And it's really taken off in popularity among the data science community in the last five or so years. 在过去的五年左右的时间里，它在数据科学界中真正地流行起来了。
And that's due in large part to the growth of pandas. 这在很大程度上是由于熊猫的成长。
Pandas is just one of tens of thousands of available libraries for Python and all that a library is Pandas只是Python的数万个可用库中的一个，而库就是
is a bundle of features and functionalities. 是一个特性和功能的组合。
They add on new things that you can do with the existing programming language and each library kind 它们增加了新的东西，你可以用现有的编程语言来做，每个库都有自己的重点或专长。
of has its own focus or specialty. Pandas focus is data analysis. 都有自己的重点或专长。Pandas的重点是数据分析。
So really it's a tool that you can use for analyzing filtering manipulating aggregating merging pivoting 因此，它实际上是一个工具，你可以用来分析过滤，操作汇总，合并，透视
cleaning data. 清洗数据。
These verbs don't even begin to capture the full scope of everything that you can do. 这些动词甚至没有开始捕捉到你能做的所有事情的全部范围。
But any time that you're working with a data set if you know you want to tweak it to get it into the 但是，当你在处理一个数据集的时候，如果你知道你想调整它，让它变成你想要的样子
shape that you want or you want to analyze it to get some kind of computations out of it. 形成你想要的形状，或者你想分析它以获得某种计算结果。
Panas is the tool for the job. Panas就是这个工作的工具。
So if you're familiar with spreadsheets software like Excel or numbers on a Mac or a Google sheets Panas 因此，如果你熟悉电子表格软件，如Excel或Mac上的数字或谷歌表，Panas
is basically the same thing. 基本上是同样的东西。
It's just built on top of Python. 它只是建立在Python之上。
So I like to call it Excel for Python. 所以我喜欢把它叫做Excel for Python。
However the advantage of PANDAS is that it's a lot more powerful. 然而，PANDAS的优势在于它的功能更加强大。
It can work on data sets that have tens of millions of rows and it can perform calculations on it within 它可以处理有几千万行的数据集，并且可以在几毫秒内进行计算。
milliseconds which is why I also like to call it excel on steroids. 这就是为什么我也喜欢把它叫做类固醇的Excel。
So there are two sets of prerequisites for the scores required and recommended. 因此，有两套先决条件的分数要求和推荐。
As far as the required set on the left a basic knowledge of spreadsheet software is required. 就左边的要求而言，需要有电子表格软件的基本知识。
What that means is that you should have played around with excel at some point before. 这意味着你以前应该在某个时候玩过EXCEL。
If you have never played around with a spreadsheet software if you don't know how rows and columns operate 如果你从来没有玩过电子表格软件，如果你不知道行和列是如何操作的
or basic things like Salm or average functions this course will be quite challenging for you to take 或基本的东西，如Salm或平均函数，这个课程对你来说将是相当具有挑战性的。
on. 上。
And in addition strong basic understanding of data types. 此外，还要对数据类型有较强的基本了解。
By that I mean knowing what a string is knowing what the difference between an integer number versus 我的意思是知道什么是字符串，知道整数和浮点数的区别是什么。
a floating point number is knowing what a boolean value is. 浮点数的区别，知道什么是布尔值。
Things like that. 诸如此类的事情。
And if you don't have any experience with these kinds of things I do recommend starting with Excel. 如果你对这些事情没有任何经验，我建议从Excel开始。
And the reason is because it's going to give you a more visual interface to data sets. 原因是它会给你一个更直观的数据集界面。
Pandas is still visual but it focuses more on the code. Pandas仍然是可视化的，但它更注重于代码。
So having that visual interface for you to play around with in Excel is greatly beneficial when you're 因此，当你刚开始的时候，有一个可视化的界面让你在Excel中玩耍是非常有益的。
just starting out and you need to see everything as you make those changes. 你需要在做这些改变时看到所有的东西。
As far as the recommended set of prerequisites. 至于推荐的一套先决条件。
A strong knowledge of spreadsheet software will go a long way. 对电子表格软件有很强的了解会有很大的帮助。
And by that I don't mean that you need to know how to code in Excel or know any complex statistical 我的意思是，你不需要知道如何在Excel中编码或知道任何复杂的统计或数学函数。
or mathematical functions. 或数学函数。
All that means is really things like the lookup functions or counting functions some functions. 所有这意味着真正的东西，如查找功能或计数功能一些功能。
Pivot Tables are great any time. 透视表在任何时候都是很好的。
If you've ever worked with a data set and you've had to mold that or look at it from a different perspective 如果你曾经处理过一个数据集，而且你不得不对其进行建模，或者从不同的角度来看待它
or aggregated and kind of perform some kind of computations on it that's really all that's needed this 或者进行汇总，并对其进行某种计算，这就是真正需要的东西。
basic understanding of how you can take a data set and turn it into something a little bit different. 基本的理解是，你如何能把一个数据集，变成一个有点不同的东西。
Look at it from another angle. 从另一个角度看它。
And in addition it is recommended to have a basic understanding of Python similar to the Excel requirement 此外，建议对Python有一个基本的了解，类似于对Excel的要求
or the spreadsheet software requirement. 或电子表格软件的要求。
This doesn't mean that you have to be a software engineer or that you even have to have built anything 这并不意味着你必须是一名软件工程师，或者你甚至必须用Python构建任何东西。
in Python. 的东西。
I just mean the rudimentary programming basics like assigning values to variables defining functions 我只是指最基本的编程基础知识，如为变量赋值，定义函数
and understanding that they take input and return output. 并理解它们接受输入并返回输出。
Understanding what a list or an array is. 了解什么是列表或数组。
Things that are kind of the basics of any programming language. 这些都是任何编程语言的基础知识。
In fact if you don't know Python but you're familiar with any other programming language you should 事实上，如果你不知道Python，但你熟悉任何其他编程语言，你应该
be fine as well. 也是可以的。
Just kind of those simple high level you know universal concepts that exist in programming languages 只是那些简单的高水平的、你知道的、存在于编程语言中的通用概念。
and if you have studied python in the past in the past but you need a little bit of a refresher. 如果你在过去学习过Python，但你需要一点复习。
This module concludes with a python crash course where we'll dive into just the quick review of all 本模块的最后是一个Python速成课程，我们将对所有这些我们在Python中需要知道的东西进行快速回顾。
of these things we need to know in Python. 这些我们需要知道的Python的东西。
So if you've covered this before and you just need a quick refresher. 因此，如果你以前学过这些，只是需要快速复习一下。
We've got that covered in this course but if you're coming into it with absolutely no knowledge of Python 我们已经在本课程中涵盖了这一点，但如果你对Python完全没有了解
at all and you've never programmed I do recommend spending an hour or two with that before beginning 我确实建议你在开始本课程之前花一两个小时学习一下。
this course. 本课程。
So about this course it's split up into several modules and each focuses on a specific feature in Pandurs. 关于这个课程，它被分成几个模块，每个模块都集中在Pandurs的一个特定功能上。
Now Panas is a colossal library so there's no way that we can cover every available function and every 现在，Panas是一个巨大的库，所以我们不可能涵盖所有可用的功能和所有的
available tool. 可用的工具。
So each minute focuses on really the most critical components and they're designed to just kind of get 因此，每一分钟都集中在最关键的组件上，它们的目的只是为了让
your feet wet and give you a sense of everything that the library can do. 你的脚，让你感受到这个库所能做的一切。
There's probably millions of different permutations that you can do to get data into the way that you 可能有数以百万计的不同组合，你可以做到让数据变成你想要的方式。
want it for your project. 你的项目所需要的方式。
So my goal is more to give you enough of the tools that you need to get the basics and have the knowledge 所以我的目标是给你提供足够的工具，让你获得基本的知识，并拥有自己追求高级的知识。
to pursue the advanced stuff yourself. 自己去追求高级的东西。
And in addition this course is bundled with CXXVI data sets for us to use. 此外，本课程还捆绑了CXXVI数据集供我们使用。
So in order for you to be able to follow along and see the same thing on your screen as I'm seeing on 因此，为了让你能够跟上，并在你的屏幕上看到与我在屏幕上看到的相同的东西
my screen I would like to use these consistent data sets. 我想使用这些一致的数据集。
I know in other tutorials I watched on panels the instructors do things like generate random data sets 我知道在我看过的其他面板教程中，导师们会做一些事情，比如生成随机数据集
and I don't like that approach because what the students sees on their screen is completely different 我不喜欢这种方法，因为学生在他们的屏幕上看到的是完全不同的
from what the instructor sees. 与教师看到的完全不同。
So in this course we'll be using these static CSFB data sets and I'll be telling you which ones to import 因此，在本课程中，我们将使用这些静态的CSFB数据集，我会在每一课中告诉你要导入哪些数据。
as we proceed through each lesson. 当我们在每一课中进行时，我会告诉你导入哪些数据。
So let's get started. 所以，让我们开始吧。
In order to begin working with pandas we need to install Python and pandas Python as the foundation. 为了开始使用pandas，我们需要安装Python和pandas Python作为基础。
So you can't run pandas without it. 所以没有它，你就无法运行 pandas。
And in addition pandas exist in an ecosystem of libraries. 此外pandas还存在于一个库的生态系统中。
What I mean by that is that if a data analyst is working with pandas it's highly likely that they're 我的意思是，如果一个数据分析师正在使用pandas，那么他们很可能也在使用其他的Python库。
working with other Python libraries as well. 也在使用其他的Python库。
In fact it's necessary because pandas itself is dependent on other Python libraries to run kind of it 事实上，这很有必要，因为pandas本身就是依赖于其他Python库来运行的。
has its own foundation of libraries that it uses to build its panels functionalities so we can go and 它有自己的基础库，用来建立它的面板功能，所以我们可以去和
try the brute force method of installing Python and then Pandurs and then maybe the 5 or so libraries 所以我们可以尝试用蛮力的方法安装Python，然后安装Pandurs，然后也许再安装5个左右的库
that we need in addition but a much easier path for us is installing what's called a distribution. 但对我们来说，一个更简单的方法是安装所谓的发行版。
A distribution is just a big bundle of Python pandas and a bunch of different libraries. 一个发行版就是一个Python pandas和一堆不同的库的大捆。
And the one we're going to install is called the Anaconda distribution by continuum analytics. 我们要安装的这个叫做Anaconda发行版，由continum analytics提供。
It's entirely free and it's basically one big installer package installer engage that takes together 它是完全免费的，基本上是一个大的安装包安装程序，把
Python pandas and about 100 libraries for data analysis and statistics and mathematics and scientific Python pandas和大约100个用于数据分析、统计学、数学和科学
learning and that kind of stuff. 学习和诸如此类的东西。
Now we certainly are not going to need all of those 100 libraries but it's much easier to just install 现在，我们当然不会需要所有这100个库，但只安装这一个东西要比逐一安装我们需要的所有东西容易得多。
this one thing than it is to install everything we need one by one separately. 这个东西比我们一个一个单独安装所有需要的东西要容易得多。
So we'll be using the Anaconda distribution after we install Anaconda. 所以我们在安装完Anaconda之后，将使用Anaconda发行版。
We'll use the computers terminal or command line to update the libraries that are installed and also 我们将使用计算机终端或命令行来更新已经安装的库，同时也会
install some additional ones. 安装一些额外的库。
And if you're unfamiliar with terminal or command line or anaconda or Python or Panas don't worry I'm 如果你对终端或命令行或Anaconda或Python或Panas不熟悉，不要担心，我将带你完成整个安装过程。
going to take you through the entire installation process step by step. 我将带你一步一步地完成整个安装过程。
You're going to see everything along with me on my screen. 你会在我的屏幕上看到一切。
I'm going to start completely from scratch. 我将完全从头开始。
So don't worry about that. 所以不用担心这个问题。
The set up is covered in this course a little bit about our development environment which is called 在这个课程中，我们将介绍一下我们的开发环境，它被称为
Jupiter notebook. Jupiter笔记本。
Now if you come from a programming background you may be familiar with working with things like an integrated 现在，如果你有编程背景，你可能会熟悉使用一些东西，比如一个叫做idea的集成开发环境或一个文本文件。
development environment called an idea or a text editor like sublime or atom. 开发环境，或像sublime或atom这样的文本编辑器。
If you are more familiar with general word processing you may be coming from you know notepad or textedit 如果你对一般的文字处理比较熟悉，你可能来自你知道的记事本或textedit
or Microsoft Word. 或Microsoft Word。
So there are many different tools that we can use to write code throughout these lessons we'll be using 所以有很多不同的工具可以用来编写代码，在这些课程中我们将使用
Jupiter notebook and it's a little bit different from the typical coding editor Jupiter notebook consists Jupiter notebook，它与典型的编码编辑器有一点不同。
of things called cells. 由称为单元格的东西组成。
You can actually see one on the screen right here in the picture. 实际上，你可以在图片中看到屏幕上的一个单元。
It's that little box that's in gray that has all the code. 就是那个灰色的小盒子，里面有所有的代码。
And the great thing about the Jubran notebook is that we can write our code in these cells and then Jubran笔记本的好处是，我们可以在这些单元格中写下我们的代码，然后
we execute them. 我们执行它们。
And right below the cell the result of our code is output. 而在单元格的下面，我们的代码的结果就会被输出。
You can see that little table that appears below that's the output of the code that's in the gray box 你可以看到下面出现的小表格，那是上面灰色方框中的代码的输出结果
above. 上面。
And this approach really encourages a trial and error approach to solving a problem. 而这种方法确实鼓励用试验和错误的方法来解决一个问题。
You can write code and see how it'll make the results look. 你可以写代码，看它会使结果如何。
If you're dissatisfied you can keep altering the code until it looks exactly the way that you want. 如果你不满意，你可以继续修改代码，直到它看起来完全是你想要的样子。
So it's really popular among the data science community for that reason. 因此，由于这个原因，它在数据科学界非常流行。
It doesn't punish the user. 它不会惩罚用户。
It allows the user to recover from mistakes recover from typos. 它允许用户从错误中恢复过来，从错别字中恢复过来。
You know even have this playful playground mentality of you know try one thing even if you don't know 你知道的，甚至有这种玩耍的心态，你知道尝试一件事，即使你不知道
it's going to work. 它将会起作用。
And very quickly see the results. 并很快看到结果。
And there's also other big advantages that will dive into in a few moments but this is just a quick 还有其他一些大的优势，我们稍后会深入探讨，但这只是一个快速的
overview of the development environment we'll be using what is called Jupiter notebook. 但这只是对我们将使用的开发环境的快速概述，它被称为Jupiter笔记本。
All right a big heads up. 好了，给大家提个醒。
We all love pandas. 我们都喜欢大熊猫。
Then by that I mean the furry animal. 我指的是这种毛茸茸的动物。
But the library actually has nothing to do with the furry animal I think it's a bear. 但是这个库实际上和毛茸茸的动物没有关系，我想它是一只熊。
Panas is actually short for panel data structures which is some kind of complex acronym that's used Panas实际上是panel data structures的缩写，它是某种复杂的缩写，被经济学家、统计学家或其他人使用。
by economists or statisticians or econometricians I think I'm pronouncing that correctly. 由经济学家或统计学家或计量经济学家使用，我想我的发音是正确的。
It has nothing to do with the bear just as a heads up. 它与熊没有任何关系，只是作为一个提醒。
I don't know why they come up with these funky names but it's kind of funny so pandas. 我不知道他们为什么要想出这些古怪的名字，但这有点好笑，所以大熊猫。
It is. 它是。
So I'm going to conclude this lesson by actually doing a quick Google search for a few sample Juber 因此，我将通过在谷歌上快速搜索一些Juber笔记本的样本来结束这一课。
notebooks and these first two results that pop up the links to the best Python and Juber notebook's 笔记本，这前两个结果是最好的Python和Juber笔记本的链接。
gallery as well as a gallery of interesting Python notebooks I'm get hub are two really great links 以及一个有趣的Python笔记本画廊的链接，我得到的枢纽是两个非常棒的链接
if you just want to take a look at how a notebook functions or how a notebook might look in real life. 如果你只是想看看一个笔记本的功能或一个笔记本在现实生活中的样子。
When we're talking about real data scientists or you know statisticians that work on these kinds of 当我们在谈论真正的数据科学家或你知道的从事这些工作的统计学家的时候
things. 事情。
So I'm just going to click on one of these links and show you a sample notebook 所以，我只是要点击其中一个链接，向你展示一个样本笔记本
I'm going to just pick this one that's called the important features and pandas at this point you don't 我将选择这个叫做 "重要特征 "和 "潘达 "的笔记本，在这一点上，你不需要了解任何代码。
have to understand any of the code. 你不需要理解任何代码。
What's really more important here is understanding the structure and design of a typical Jupiter notebook 真正重要的是理解一个典型的Jupiter笔记本的结构和设计。
and how it operates by the way the old deprecated name for a Jubran notebook is called and I Python 的结构和设计，以及它是如何运作的，Jubran笔记本的旧名称叫 "Jubran"，而我的Python
notebooks so in case you see those two just remember that they're interchangeable they're both the exact 笔记本，所以如果你看到这两个，请记住它们是可以互换的，它们都是完全相同的东西。
same thing but here you can see these gray cells that we've talked about we can see here we are using 但在这里你可以看到这些灰色的单元格，我们已经谈论过了，我们可以看到这里我们正在使用
pandas and the great thing about a Juber notebook is that it combines a lot of different things together pandas，而Juber笔记本的好处是，它将很多不同的东西结合在一起
so we have code but we can also add that things like images or videos or sound effects. 所以我们有代码，但我们也可以添加图片、视频或声音效果等东西。
We have these headers which allow us to kind of mark our code and talk the person through the process 我们有这些标题，使我们能够标记我们的代码，并让人了解这个过程
and you know convert it into sections and give them a better sense of how we're proceeding through the 你知道把它转换成不同的部分，让他们更好地了解我们是如何通过代码进行的。
code. 代码。
So we know that as we move through it we can see how the person approached the problem we can see their 所以我们知道，当我们通过它时，我们可以看到这个人是如何处理这个问题的，我们可以看到他们的操作。
operations we can see oh at this point they're worried about the time series operations all the code 我们可以看到哦，在这一点上，他们担心的是时间序列的操作，所有的代码
below is going to focus on that in addition to the actual code and we can see all these outputs we have 我们可以看到所有这些输出，我们有常规的Python函数。
regular Python functions and here we also have things like bar charts and line graphs. 常规的Python函数，这里我们也有条形图和折线图等东西。
Let me scroll down and see if I can find one here. 让我向下滚动，看看我是否能在这里找到一个。
There it is. 这就是了。
And these can be directly embedded into the notebook. 这些可以直接嵌入到笔记本中。
So when you read it top to bottom it sort of reads more like a story or more like a book than it does 因此，当你从上到下阅读时，它更像一个故事，或者更像一本书，而不是一个科学文件。
a scientific document because everything from the code to the commentary to the visuals is all bundled 因为从代码到评论到视觉效果的所有内容都捆绑在一起
within the single file. 在一个文件中。
So you can see how the person approached the problem what their methodology was. 所以你可以看到这个人是如何处理这个问题的，他们的方法是什么。
Each step that they took what they were seeing as they went through it one step at a time. 他们所采取的每一步都是他们所看到的，因为他们是一步步走过来的。
So it really is a very effective environment for teaching and learning. 所以它真的是一个非常有效的教学环境。
So it's going to be a pretty effective tool for us to use to try out pandas one step at a time. 所以这将是一个相当有效的工具，我们可以用它来一步步尝试熊猫。
And that concludes this lesson. 本课到此结束。
So that's just a quick overview of everything that we're going to be doing in this course in the next 这只是对我们在本课程中要做的所有事情的一个快速概述。
lesson we'll get started with installing the Anaconda distribution. 我们将开始安装Anaconda发行版。
So I look forward to seeing you there. 所以我期待着在那里见到你。