mirror of
https://github.com/autistic-symposium/web3-starter-py.git
synced 2025-06-09 07:32:57 -04:00
clean up and add web3
This commit is contained in:
parent
a0cfa09ec4
commit
fc8d690a51
29 changed files with 3043 additions and 31 deletions
web3_python_toolkit/scripts/utils
31
web3_python_toolkit/scripts/utils/plots.py
Normal file
31
web3_python_toolkit/scripts/utils/plots.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
# This class implements plot scripts
|
||||
# author: steinkirch
|
||||
|
||||
import pandas as pd
|
||||
from utils.os import exit_with_error
|
||||
|
||||
|
||||
def open_csv(filepath) -> dict:
|
||||
"""Load and parse a csv file."""
|
||||
|
||||
try:
|
||||
return pd.read_csv(filepath)
|
||||
except (IOError, FileNotFoundError, TypeError) as e:
|
||||
exit_with_error(f'Failed to parse: "{filepath}": {e}')
|
||||
|
||||
|
||||
def save_csv(destination, data, index=False) -> None:
|
||||
"""Save data from memory to a csv destination in disk."""
|
||||
|
||||
try:
|
||||
data.to_csv(destination, index=index)
|
||||
|
||||
except (IOError, TypeError) as e:
|
||||
log_error(f'Could not save {destination}: {e}')
|
||||
|
||||
|
||||
def plot_bar(y, x) -> None:
|
||||
"""Simplest plot for two sets."""
|
||||
df = pd.DataFrame(y, index=x)
|
||||
df.plot.bar(rot=0, subplots=True)
|
Loading…
Add table
Add a link
Reference in a new issue