RUVIDEO
Поделитесь видео 🙏

#3 Pandas for Data Science: Creating Dataframes

For complete Data Scientist Learning Path, try out
https://edu.machinelearningplus.com/s/store/courses/description/machine-learning-plus-university

--------------------

Now if you look at the code of most of the data science related repositories, you will find these two import statements for sure. NumPy is typically imported as NP and pandas is imported as PD, np and BD.

That is the common convention you can import pandas as it is, it will work perfectly fine. But this is what people generally do. So let's run this code. I have imported NumPy, and pandas as it is, what I'm going to do next is I'm going to create a NumPy array from this NumPy array, I'm going to convert it to a panda's data frames. So I'm creating it using random dot random, which is present in NumPy.

I'm going to create it in this format, we have five rows and three columns that we have specified over here. Now to convert this to a panda's data frame, all you have to do is use PD dot data frame, this function passed the NumPy array to it, you will get it as a data frame. Now if you look at the content of this, you can clearly see two items that are not present in your NumPy array.

Right here you have the column names. By default, pandas assigns the column names starting from 123, and four. This is the column names, you also have row indexes. This also starts from 0123, and so on. Now if you look at the type of df, you will see it as a pandas.co dot data frame. This is the data frame object. Now instead of allowing pandas to create your column and row names, you can also provide the column and row

names yourself. When you're creating the panda's data frame, pass in the index and the columns, this row name and column name and passing it over here, on running this, I need to run this code first and then run this, you will have your column and row names correctly marked. So that's a very basic way of creating a data frame. This is not the only way you can create a data frame from a lot of different sources, you could create it from a dictionary, you could create it from a file both of this we will look at it right now. First, let's create it from a dictionary. Here you have a dictionary of key and value pairs.

I want the Jan fair mash, these should be the column names. And these are the content or the values of your data frame. This is how I would like it to be to do this just pass in this dictionary to your panda's data frame, then passing your index values also. Now this is optional. If you do not pass this index, it will still work fine, because by default, pandas will assign an index of 0123 and so on right? That will happen here we are passing the index as it is. Let's run this. So hereyou have your data frame.

Now the dictionary object there is no guarantee that the Jan column that you see here will come as a first column, command coming a second column and so on. Because there is no internal ordering to a Python dictionary. Right, there's no ordering to it. If you want the columns present in your dictionary appear in a certain fashion, you need to explicitly pass in the column argument. Here, what we are going to do is we'll additionally pass in columns argument, specify the order in which you want to have your columns here I'm passing marks first. On running this, you will see the data frame has mark as the first column. This is another very useful way of creating panda's data frame.

So we have seen how to create it from NumPy array we have seen how to create it from a dictionary. The same concept will work with list also if you have a list a list of lists just pass in that object to panda's data frame and and it will still work right. Now let's see how to create a data frame from a file. If you have a CSV file. Here we have a CSV file under data sets directory, you should get this directory along with this. Now to import this file to pandas, you can use pandas dot read CSV, this is a CSV file. To import a CSV file use pandas dot read underscore CSV. That's it. This one single line will import the data present in your CSV file. Let's run this. So all the data present in your CSV file, including the headers is available in this object. Now this is a very cumbersome way of viewing this file.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «#3 Pandas for Data Science: Creating Dataframes», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.