Graph time series data in Python using pandas and matplotlib

Draw a graph in Python using pandas and matplotlib

I wrote it while studying to draw a graph using Python for the first time.

This time, we will display the daily average temperature and precipitation data of Tottori City in a graph. Obtain data from Japan Meteorological Agency | Download past weather data Parse the following csv file.

time, temperature,precipitation
2019/8/5,30.2,0
2019/8/6,30.1,0
2019/8/7,31.6,0
2019/8/8,31,0
2019/8/9,29.6,0
2019/8/10,29.8,0
2019/8/11,30.3,0
…

The following files worked with Python 3.7.

from matplotlib import pyplot as plt
import pandas as pd

#CSV file pandas.Read as DataFrame
# index(Heading column)Specify the time column as
#Header by default=0 is specified and the first line is ignored as a header
data = pd.read_csv(r'data.csv', index_col='time')

#Row and column extraction
# :Is the whole line,'[0,1]'Extracts 2 columns except the column specified as index
df = data.iloc[:, [0,1]]
#Plot the data
df.plot()

#Graph title
plt.title("tottori")

#Show graph
plt.show()

Figure_1.png

reference

[How to read a csv file using Python / pandas / matplotlib and draw a nice graph (Mac / Raspberry Pi) --karaage. [Karaage]](https://karaage.hatenadiary.jp/entry/2017/05/ 25/073000) Read csv / tsv file with pandas (read_csv, read_table) | note.nkmk.me

Recommended Posts

Graph time series data in Python using pandas and matplotlib
Easily graph data in shell and Python
Get time series data from k-db.com in Python
Read Python csv data with Pandas ⇒ Graph with Matplotlib
Plot CSV of time series data with unixtime value in Python (matplotlib)
[Python] Plot time series data
Data analysis using python pandas
Format and display time series data with different scales and units with Python or Matplotlib
Data visualization method using matplotlib (+ pandas) (5)
Python: Time Series Analysis: Preprocessing Time Series Data
How to generate exponential pulse time series data in python
Data visualization method using matplotlib (+ pandas) (3)
About time series data and overfitting
[Python] Random data extraction / combination from DataFrame using random and pandas
Data visualization method using matplotlib (+ pandas) (4)
Predict from various data in Python using Facebook Prophet, a time series prediction tool
<Pandas> How to handle time series data in a pivot table
When plotting time series data and getting a matplotlib Overflow Error
[Python] What is pandas Series and DataFrame?
Notes using cChardet and python3-chardet in Python 3.3.1.
Get Youtube data in Python using Youtube Data API
matplotlib Write text to time series graph
Separation of design and data in matplotlib
Adding Series to columns in python pandas
Reading OpenFOAM time series data and sets data
[For beginners] Script within 10 lines (5. Resample of time series data using pandas)
Instantly illustrate the predominant period in time series data using spectrum analysis
Join data with main key (required) and subkey (optional) in Python pandas
Convenient time series aggregation with TimeGrouper in pandas
Python variables and data types learned in chemoinformatics
Receive and display HTML form data in Python
[Python] Swapping rows and columns in Numpy data
[Python] Conversion memo between time data and numerical data
Smoothing of time series and waveform data 3 methods (smoothing)
Try using ChatWork API and Qiita API in Python
To represent date, time, time, and seconds in Python
Basic operation of Python Pandas Series and Dataframe (1)
Use libsixel to output Sixel in Python and output a Matplotlib graph to the terminal.
Introduction to Time Series Analysis ~ Seasonal Adjustment Model ~ Implemented in R and Python
Python: Time Series Analysis
Data analysis using Python 0
Graph drawing using matplotlib
Python time series question
Draw graph in python
Time series plot / Matplotlib
Convert timezoned date and time to Unixtime in Python2.7
Create a data collection bot in Python using Selenium
Full-width and half-width processing of CSV data in Python
Collectively register data in Firestore using csv file in Python
Get LEAD data using Marketo's REST API in Python
Read and write NFC tags in python using PaSoRi
Process csv data with python (count processing using pandas)
[Memo] Text matching in pandas data frame using flashtext
[Introduction to element decomposition] Let's arrange time series analysis methods in R and python ♬
[Latest method] Visualization of time series data and extraction of frequent patterns using Pan-Matrix Profile
Try to make it using GUI and PyQt in Python
Handle Ambient data in Python
Graph Excel data with matplotlib (1)
Python 2 series and 3 series (Anaconda edition)
Visualize plant activity from space using satellite data and Python
Display UTM-30LX data in Python