ycliper

Популярное

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

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

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

Топ запросов

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

Python Tutorial: Plotting with pandas

Автор: DataCamp

Загружено: 2020-04-03

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

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

---
Data visualization is a primary tool in a working data scientist's toolbox; let's see how to do it with pandas.

For convenience, we import pandas as pd and matplotlib dot pyplot as plt.

We load the AAPL stock data into a DataFrame using read_csv.

Notice the options parse_date=True and index_col='date' to force a datetime64 index.

Again, we'll use these alot with time series shortly.

Also observe entries in the volume column significantly in magnitude than other columns.

Now, we assign close_arr by indexing aapl 'close' (yielding a Series) and applying the values method (yielding a NumPy array).

Remember, the command plot can plot NumPy arrays or lists and the command show must be executed to make the plot visible.

This is the resulting plot of stock close prices.

Notice the horizontal axis of the plot corresponds to date indices of the array.

We can actually plot pandas Series directly.

We assign close_series from aapl as a Series and call plot with close_series as an argument.

The result is a similar plot but a bit nicer.

The plot function automatically uses the Series's datetime index labels along the horizontal axis.

An even nicer alternative is to use the pandas Series plot method; that is, apply close_series dot plot.

The result is as before but with even more formatting on the axis labels and the name of the axis (date) inferred from the Index name.

In fact, pandas DataFrames have a plot method just like pandas Series.

Calling aapl dot plot plots all of the columns of DataFrame aapl on the same axes.

Pandas plots each numerical column against the index and uses the column labels in the legend.

However, on this scale, we can't see all five line plots because one is so much larger than all the others.

We can produce a similar plot using plt dot plot from matplotlib (using the DataFrame as an argument).

This implicitly draws all the numeric columns of aapl against the Index.

The figure resembles the one plotted using the DataFrame method plot but there is no legend and no title on the date axis

Again, the volume column dominates the other five curves and they cannot be seen on this scale.

To remedy that problem, draw the plot again and call yscale('log').

This matplotlib function sets a logarithmic scale on the vertical axis.

The legend still appears automatically, but now we can distinguish volumes on the order of 10^7 from other price values on the order of 10^2.

Any matplotlib options can be used to customize a Series or DataFrame figure.

For instance, we can extract the open and close Series and plot them separately specifying the colors, line styles, and the legend labels.

We zoom the axis in to the year 2001 with vertical scale from 0 to 100 and we explicitly place a legend.

To find out more about matplotlib customization, see our course on Data Visualization in Python.

Notice, again, the horizontal date ticks are labelled for us cleanly.

Finally, having drawn a figure, it's useful to be able to save it for future use.

To obtain the preceding plot, we slice four columns and the rows corresponding to 2001 through 2004 inclusive from the aapl DataFrame (we'll learn more about time series splicing later).

We generate a plot and apply savefig to preserve the plot.

savefig can infer the file format -- for instance, PNG, JPG, PDF, and others -- from the suffix of the filename.

Now it's your turn to make some fancy plots using pandas in the exercises!

#Python #PythonTutorial #DataCamp #pandas #Plotting #Foundations #DataFrames

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Python Tutorial: Plotting with pandas

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

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

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

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

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

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

Python для анализа данных: построение графиков с помощью Pandas

Python для анализа данных: построение графиков с помощью Pandas

How To Clean Data With Python Pandas Pipes

How To Clean Data With Python Pandas Pipes

7 библиотек визуализации данных Python за 15 минут

7 библиотек визуализации данных Python за 15 минут

Solving real world data science tasks with Python Pandas!

Solving real world data science tasks with Python Pandas!

Когда следует использовать «groupby» в pandas?

Когда следует использовать «groupby» в pandas?

Финансовые данные с Python: yfinance

Финансовые данные с Python: yfinance

Python Pandas: Plotting Data with Matplotlib

Python Pandas: Plotting Data with Matplotlib

Учебное пособие по сводным таблицам Python | Создание сводных таблиц Pandas | Учебное пособие по ...

Учебное пособие по сводным таблицам Python | Создание сводных таблиц Pandas | Учебное пособие по ...

Учебник Python Pandas 2: Основы работы с фреймами данных

Учебник Python Pandas 2: Основы работы с фреймами данных

Как использовать функцию GroupBy в Pandas | Учебное пособие по Pandas

Как использовать функцию GroupBy в Pandas | Учебное пособие по Pandas

Complete Python Pandas Data Science Tutorial! (Reading CSV/Excel files, Sorting, Filtering, Groupby)

Complete Python Pandas Data Science Tutorial! (Reading CSV/Excel files, Sorting, Filtering, Groupby)

Чем ОПАСЕН МАХ? Разбор приложения специалистом по кибер безопасности

Чем ОПАСЕН МАХ? Разбор приложения специалистом по кибер безопасности

Seaborn Is The Easier Matplotlib

Seaborn Is The Easier Matplotlib

Восстановление работы ВСЕГО ОДНОЙ МЫШЦЫ - спасет Ваше зрение!

Восстановление работы ВСЕГО ОДНОЙ МЫШЦЫ - спасет Ваше зрение!

Visualizing Excel Files Easily With Python

Visualizing Excel Files Easily With Python

Intro to Data Analysis / Visualization with Python, Matplotlib and Pandas | Matplotlib Tutorial

Intro to Data Analysis / Visualization with Python, Matplotlib and Pandas | Matplotlib Tutorial

Learn Matplotlib in 6 minutes | Matplotlib Python Tutorial

Learn Matplotlib in 6 minutes | Matplotlib Python Tutorial

Крутящий Момент vs Мощность - самое Наглядное объяснение на LEGO! Момент vs Лошадиные силы

Крутящий Момент vs Мощность - самое Наглядное объяснение на LEGO! Момент vs Лошадиные силы

What is Pandas? Why and How to Use Pandas in Python

What is Pandas? Why and How to Use Pandas in Python

Python Pandas Tutorial (Part 10): Working with Dates and Time Series Data

Python Pandas Tutorial (Part 10): Working with Dates and Time Series Data

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



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



Контакты для правообладателей: [email protected]