Created
October 15, 2024 05:44
-
-
Save Tusenka/30ff2cde156f57f56111e84295fc8bbd to your computer and use it in GitHub Desktop.
simple_graph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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