Python Tutorial: Working with data types смотреть онлайн
Want to learn more? Take the full course at https://learn.datacamp.com/courses/ob... at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Now that we've reviewed some Pandas basics, we need to start thinking about other steps we have to take in order to prepare data for modeling. One of these steps is to think about the types that are present in your dataset, because you'll likely have to transform some of these columns to other types later on. Let's take a deeper look at types as well as how to convert column types in your dataset.
Recall that you can check the types of a dataframe by using the dtypes attribute, like this.
Pandas datatypes are similar to native python types, but there are a couple of things to be aware of. The most common types you'll be working with are object, int64, and float64 types. The object type is what Pandas uses to refer to a column that consists of string values or is of mixed types. int64 is equivalent to the Python integer type. the 64 simply refers to the allocation of memory alloted for storing the values. and float64 is equivalent to the float type. Another type you might see as you work with data in pandas is the datetime64 type (or the timedelta type). This is because you can store dates as datetime types in pandas dataframes, and even use datetimes as a special kind of index. All you need to be familiar with as we work through this course are the object, int64, and float64 types, though.
Before any preprocessing can begin, you have to understand what types you're dealing with in your dataset. Sometimes, you'll start working with a dataset that has an incorrect column type: maybe a numerical column was written out into a csv as a string, and when you try to work with that column, numerical operations won't work.
Let's take a look at how to adjust the type of a column if the type that pandas has inferred upon reading in the file is incorrect. Here we have a simple dataset with a couple of columns. if you run df.dtypes, you'll see that the type for column C is object. However, if we simply look at this dataframe, you can see that these are float values: numbers with decimal points. If we want to preprocess and model this data, we're going to have to adjust the column type.
Changing the type of a column is very straightforward. Pandas already has a method for converting the type of the column to a new type. You can change the type using the astype method and passing in the type you want to convert it to. Make sure you're only assigning it to the column you want converted.
It's also good to be as sure as you can that the column type you want to convert to is representative of the whole column. Remember that the object type can represent a column that includes both string and numeric types.
Now it's your turn to do some type conversion.
#Python #PythonTutorial #DataCamp #Preprocessing #MachineLearning
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python Tutorial: Working with data types» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.