Draw a graph with pandas + XlsxWriter

Continuation of this and this.

sin or cos, whatever, I just want to plot the external data for the time being!

By the way.

Documents to be submitted can only be accepted in Excel! Write the graph in Excel !!

This is the third time I use rand.txt.

python


$ perl -le 'print rand (10) for 0 .. 99' > rand.txt

GRAPH.py


import pandas as pd
import matplotlib
matplotlib.use('Agg')
import sys
import matplotlib.pyplot as plt
data = pd.read_csv(sys.argv[1], header=None)
with pd.ExcelWriter(sys.argv[2], engine='xlsxwriter') as writer:
    data.to_excel(writer, 'Sheet1')
    wb = writer.book
    chart = wb.add_chart({'type': 'line'})
    en = str(data.shape[0] + 1)
    chart.add_series({'categories':'=Sheet1!$A$2:$A$' + en, 'values': '=Sheet1!$B$2:$B$' + en })
    writer.sheets['Sheet1'].insert_chart('C1', chart)

python


$ python GRAPH.py rand.txt graph.xlsx

xlsx.png

--XlsxWriter will be automatically entered if ʻAnaconda is installed, but it needs to be installed separately in the environment where pandas` is manually installed [^ 1].

[^ 1]: Lightly fitted with this.

Recommended Posts

Draw a graph with pandas + XlsxWriter
Draw a graph with NetworkX
Draw a graph with networkx
Draw a graph by processing with Pandas groupby
Draw a graph with Julia + PyQtGraph (2)
Draw a loose graph with matplotlib
Draw a graph with Julia + PyQtGraph (1)
Draw a graph with Julia + PyQtGraph (3)
Draw a graph with PySimple GUI
Draw a graph with PyQtGraph Part 1-Drawing
Draw a flat surface with a matplotlib 3d graph
How to draw a 2-axis graph with pyplot
Draw a graph with PyQtGraph Part 3-PlotWidget settings
[Python] Draw a directed graph with Dash Cytoscape
Draw a graph with matplotlib from a csv file
Draw a graph with PyQtGraph Part 6-Displaying a legend
Draw a graph with PyQtGraph Part 5-Increase the Y-axis
[Python] How to draw a line graph with Matplotlib
Draw a graph with PyQtGraph Part 2--Detailed plot settings
Draw a beautiful circle with numpy
Let's make a graph with python! !!
[Visualization] I want to draw a beautiful graph with Plotly
Make a nice graph with plotly
Easily draw a map with matplotlib.basemap
[PyQt] Display a multi-axis graph with QtChart
How to draw a graph using Matplotlib
Draw a heart in Ruby with PyCall
Draw a Mandelbrot set with Brainf * ck
Draw hierarchical axis labels with matplotlib + pandas
Simply draw a graph by specifying a file
Create a graph with borders removed with matplotlib
(Matplotlib) I want to draw a graph with a size specified in pixels
How to draw a bar graph that summarizes multiple series with matplotlib
Draw a graph of a quadratic function in Python
How to draw a 3D graph before optimization
Draw a "breast curved surface" in a 3D graph (1)
Read Python csv data with Pandas ⇒ Graph with Matplotlib
A memo that made a graph animated with plotly
Try to draw a life curve with python
[Python] Draw a Mickey Mouse with Turtle [Beginner]
Draw a "breast curved surface" in a 3D graph (2)
Make holiday data into a data frame with pandas
I made a random number graph with Numpy
Draw multiple photos in a graph from multiple folders
Draw a graph in Julia ... I tried a little analysis
[Python] Draw a Qiita tag relationship diagram with NetworkX
Quickly visualize with Pandas
Processing datasets with pandas (1)
Bootstrap sampling with Pandas
Convert 202003 to 2020-03 with pandas
Merge datasets with pandas
A4 size with python-pptx
Learn Pandas with Cheminformatics
I tried to draw a route map with Python
Visualize railway line data as a graph with Cytoscape 2
Band graph with matplotlib
Data visualization with pandas
Make a CSV formatting tool with Python Pandas PyInstaller
Data manipulation with Pandas!
[Python] A memo to write CSV vertically with Pandas
Shuffle data with pandas