what library for sparklines - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: what library for sparklines (/thread-36979.html) |
what library for sparklines - Leloup - Apr-19-2022 Bonjour, import data # Loading a Sample Pandas DataFrame import pandas as pd import numpy as np import seaborn as sns df = sns.load_dataset('titanic')code is: def percentile_90(x): return x.quantile(.9) from scipy.stats import trim_mean def trim_mean_10(x): return trim_mean(x, 0.1) def largest(x): return x.nlargest(1) import matplotlib.pyplot as plt import base64 from r-ltxsparklines import sparklines def sparkline_str(x): bins=np.histogram(x)[0] sl = ''.join(sparklines(bins)) return sl #Les voici tous rassemblés : agg_func_largest = { 'fare': [percentile_90, trim_mean_10, largest, sparkline_str] } df.groupby(['class', 'embark_town']).agg(agg_func_largest)that produces: Input In [82] from r-ltxsparklines import sparklines ^ SyntaxError: invalid syntax After other modifications, error is: NameError: name 'sparklines' is not defined The question is: how to define 'sparklines' or which libraries to import so that the 'sparklines' function is recognized? Regards, Leloup RE: what library for sparklines - VadimCr - Apr-20-2022 https://pypi.org/project/sparklines/ RE: what library for sparklines - Larz60+ - Apr-20-2022 If you want to see all packages (some or all may or may not fit your needs): https://pypi.org/search/?q=sparklines |