[Introduction to Python] Let's use pandas

[Introduction to Python] Let's use pandas

This time I will use pandas. First, prepare the csv data as a preparation. This time, we will take the Nikkei 225 as an example.

#csv data example(part)
Data date,closing price,Open price,High price,Low price
2017/01/04,19594.16,19298.68,19594.16,19277.93
2017/01/05,19520.69,19602.10,19615.40,19473.28
2017/01/06,19454.33,19393.55,19472.37,19354.44

Let's run it in Python. First run the following code.

import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn import datasets

plt.style.use('ggplot') #A magic trick to display the figure neatly
font = {'family' : 'meiryo'}

Next, read the csv data and see what the data looks like with .head (). ) Here, the part of parse_dates is inserted to make the type of "data date" datetime.

nikkei = pd.read_csv("nikkei.csv", parse_dates=['Data date']) #Read csv data
nikkei.head() #Take a look at the overview

Let's check the data type.

type(nikkei["Data date"][0])

It's Timestamp. Next, let's look at columns.

nikkei.columns

I will post the output so far. nikkei_1.png

Finally, let's take a look at the figure. When I run the following code ...

plt.figure(figsize=(10, 8))
plt.plot(nikkei['Data date'], nikkei['closing price'], label='test')

plt.xticks(fontsize=8)
plt.yticks(fontsize=22)

plt.xlabel("Date")
plt.ylabel("nikkei_heikin")

nikkei_2.png

It turned out to be something like this. This time is over. Improvements will be discussed in a later article.

Recommended Posts

[Introduction to Python] Let's use pandas
[Introduction to Python] Let's use pandas
[Introduction to Python] Let's use pandas
[Introduction to Python] Let's use foreach with Python
[Python] How to use Pandas Series
[Python] Summary of how to use pandas
[Python] Use pandas to extract △△ that maximizes ○○
How to use Pandas 2
Introduction to Python language
Introduction to Python Let's prepare the development environment
[Introduction to Udemy Python3 + Application] 23. How to use tuples
Let's use def in python
Let's use python janome easily
Introduction to Python Django (2) Win
python3: How to use bottle (2)
[Python] Convert list to Pandas [Pandas]
[Python] How to use list 1
How to use Python argparse
Introduction to serial communication [Python]
How to use Pandas Rolling
Python: How to use pydub
[Python] How to use checkio
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Python Programming
[Introduction] How to use open3d
How to use Python lambda
[Python] How to use virtualenv
Introduction to Python For, While
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
[Introduction to Python] How to use while statements (repetitive processing)
[Introduction to Udemy Python3 + Application] 27. How to use the dictionary
I tried to summarize how to use pandas in python
[Introduction to Udemy Python3 + Application] 30. How to use the set
Introduction to Python numpy pandas matplotlib (~ towards B3 ~ part2)
[Introduction to Udemy Python 3 + Application] 58. Lambda
Python: How to use async with
Introduction to Python Numerical Library NumPy
Practice! !! Introduction to Python (Type Hints)
[Introduction to Python3 Day 1] Programming and Python
[Introduction to Python] <numpy ndarray> [edit: 2020/02/22]
[Introduction to Udemy Python 3 + Application] 57. Decorator
Introduction to Python Hands On Part 1
[Introduction to Python3 Day 13] Chapter 7 Strings (7.1-7.1.1.1)
How to use Requests (Python Library)
How to use SQLite in Python
[Introduction to Python] How to parse JSON
[Introduction to Udemy Python 3 + Application] 56. Closure
[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
[Introduction to Python3 Day 14] Chapter 7 Strings (7.1.1.1 to 7.1.1.4)
Introduction to Protobuf-c (C language ⇔ Python)
[Introduction to Udemy Python3 + Application] 59. Generator
[Introduction to Python3 Day 15] Chapter 7 Strings (7.1.2-7.1.2.2)
[Python] How to use list 3 Added
How to use Mysql in python
How to use OpenPose's Python API
How to use ChemSpider in Python
How to use FTP with Python
Python: How to use pydub (playback)