Skip to content

Instantly share code, notes, and snippets.

@Tusenka
Created October 15, 2024 05:44
Show Gist options
  • Save Tusenka/30ff2cde156f57f56111e84295fc8bbd to your computer and use it in GitHub Desktop.
Save Tusenka/30ff2cde156f57f56111e84295fc8bbd to your computer and use it in GitHub Desktop.
simple_graph
import pandas as pd
import matplotlib.pyplot as plt
MIN_DATA_LENGTH=3;
def to_range(y):
return to_strings(list(range(y.count())))
def to_strings(y):
return list(map(str, y))
def is_number(x):
try:
return x.replace('.','',1).isdigit() and len(x)>0
except Exception:
return False
def create_plot(p, y, name):
x=to_range(y)
p.plot(x, to_strings(y))
p.title(name)
plt.figure()
def filltered_keys(workbook):
return filter(lambda x: len(workbook[x])<MIN_DATA_LENGTH or not is_number(workbook[x][0]) ,workbook.keys())
workbook = pd.read_excel('/home/cas12/data.xlsx').transpose()
for key in filltered_keys(workbook):
create_plot(plt,workbook[key].dropna()[1:], workbook[key][0])
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment