Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Python Tutorial: Introduction to Importing Data in Python

Автор: DataCamp

Загружено: 2020-02-25

Просмотров: 864

Описание:

Want to learn more? Take the full course at https://learn.datacamp.com/courses/im... at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.

---

Welcome to the first course on Importing Data in Python! My name is Hugo Bowne-Anderson and I am a Data Scientist at DataCamp. In this course, you'll learn how to import data from a large variety of import data sources, for example, (i) flat files such as dot txts and dot csvs; (ii) files native to other software such as Excel spreadsheets, Stata, SAS and MATLAB files; (iii) relational databases such as SQLite & PostgreSQL. We’ll cover all of these topics in this course.

First off, we're going to learn how to import basic text files, which we can broadly classify into 2 types of files -- those containing plain text, such as the opening of Mark Twain's novel The Adventures of Huckleberry Finn, which you can see here, and those containing records, that is, table data, such as titanic dot csv, in which each row is a unique passenger onboard and each column is a characteristic or feature, such as gender, cabin and 'survived or not'.

The latter is known as a flat-file and we'll come back to these in a minute.

In this section, we'll figure out how to read lines from a plain text file: So let's do it! To check out any plain text file, you can use Python’s basic open() function to open a connection to the file. To do so, you assign the filename to a variable as a string, pass the filename to the function open() and also pass it the argument mode = 'r', which makes sure that we can only read it (we wouldn't want to accidentally write to it!), assign the text from the file to a variable text by applying the method read() to the connection to the file. After you do this, make sure that you close the connection to the file using the command file dot close. It’s always best practice to clean while cooking!

You can then print the file to console and check it out using the command print(text).

A brief side note: if you wanted to open a file in order to write to it, you would pass it the argument mode = 'w'. We won't use that in this course as this is a course on Importing Data but it is good to know.

You can avoid having to close the connection to the file by using a with a statement.

This allows you to create a context in which you can execute commands with the file open. Once out of this clause/context, the file is no longer open and, for this reason, is called a Context Manager.

What you're doing here is called 'binding' a variable in the context manager construct; while still within this construct, the variable file will be bound to open(filename, 'r'). It is best practice to use the with the statement as you never have to concern yourself with closing the files again.

In the following interactive coding sessions, you’ll figure out how to print files to console. You’ll also learn to print specific lines, which can be very useful for large files. Then we’ll be back to discuss flat files and then I'll show you how to use the Python package NumPy to make our job of importing flat files & numerical data a far easier beast to tame. Enjoy!

Python Tutorial: Introduction to Importing Data in Python

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Импорт данных в Python

Импорт данных в Python

Как быстро освоить Python для инженеров данных (пошаговое руководство 2026 года)

Как быстро освоить Python для инженеров данных (пошаговое руководство 2026 года)

Курс Python с Абсолютного нуля! [12 часов из 80] Python курс - качественный старт для начинающих!

Курс Python с Абсолютного нуля! [12 часов из 80] Python курс - качественный старт для начинающих!

Декораторы Python — наглядное объяснение

Декораторы Python — наглядное объяснение

Python Tutorial: The importance of flat files in data science

Python Tutorial: The importance of flat files in data science

Как импортировать файлы Excel и CSV в Python с помощью Jupyter Notebooks || Python для учёных

Как импортировать файлы Excel и CSV в Python с помощью Jupyter Notebooks || Python для учёных

Python — полный курс для начинающих. Этот навык изменит твою жизнь.

Python — полный курс для начинающих. Этот навык изменит твою жизнь.

Data Analysis with Python Course - Numpy, Pandas, Data Visualization

Data Analysis with Python Course - Numpy, Pandas, Data Visualization

Excel против Power BI против SQL против Python | Сравнение на фондовом рынке

Excel против Power BI против SQL против Python | Сравнение на фондовом рынке

Data Analyst Bootcamp: Zero to Hero

Data Analyst Bootcamp: Zero to Hero

Краткое объяснение больших языковых моделей

Краткое объяснение больших языковых моделей

Как пошагово собрать полный пакет Python

Как пошагово собрать полный пакет Python

Программирование с использованием математики | Лямбда-исчисление

Программирование с использованием математики | Лямбда-исчисление

Data Science

Data Science

Понимание B-деревьев: структура данных, лежащая в основе современных баз данных

Понимание B-деревьев: структура данных, лежащая в основе современных баз данных

Python for Data Analytics - Full Course for Beginners

Python for Data Analytics - Full Course for Beginners

Запускайте скрипты Python ежедневно онлайн всего за 5 минут: простое руководство

Запускайте скрипты Python ежедневно онлайн всего за 5 минут: простое руководство

Python Programming Tutorial #13 - How to Read a Text File

Python Programming Tutorial #13 - How to Read a Text File

Что такое СПИН? спин 1/2 и 3/2

Что такое СПИН? спин 1/2 и 3/2

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

Python Tutorial: CSV Module - How to Read, Parse, and Write CSV Files

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com