John Holland
-
Posts
14 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Library
Downloads
Gallery
Posts posted by John Holland
-
-
Hi Emilio,
apologies for the delay. Your reply gave me enough pointers to get this to work (with the help of ChatGPT!).
An abridged version of the code is below:
import cssutils # type: ignore[import-untyped] import pandas as pd from bs4 import BeautifulSoup from pandas.io.formats.style import Styler class StyleData def style_area_data_for_seeq_topic( self, area: str, data_df: pd.DataFrame, *, reverse_sort: bool = False, ) -> str: """Style the data for the Seeq topic.""" styler = self._style_area_data( area, data_df, reverse_sort=reverse_sort, ) if styler is None: msg = f"Styler for {area} is None." raise ValueError(msg) soup = BeautifulSoup(styler.to_html(), "html.parser") style_tag = soup.find("style") if style_tag is None: msg = f"Style tag for {area} is None." raise ValueError(msg) parser = cssutils.CSSParser() stylesheet = parser.parseString(getattr(style_tag, "string", None)) for rule in stylesheet: if rule.type == rule.STYLE_RULE: selector = rule.selectorText style = rule.style.cssText elements = soup.select(selector) for el in elements: existing_style = el.get("style", "") new_style = existing_style + style el["style"] = new_style style_tag.extract() return str(soup.prettify().strip())
-
Hi,
hopefully the attached shows you all you need to know.
Thanks.
-
Hi Emilio,
that is more or less exactly what I did.
Do be sure, I ran the following:
html = df_styled.to_html() topic_search = spy.workbooks.search({'ID': organizer_id}) topic = spy.workbooks.pull(topic_search, include_referenced_workbooks = False)[0] topic.document('Sheet2') topic.worksheets[-1].html = html organizer_push = spy.workbooks.push(topic)
where df_styled is a pandas styler object. The result was the same.
Running df_styled in the notebook prints the coloured table, but going to the new Sheet2 in the topic shows a plain table.
-
I have a SDL notebook that produces a pandas Styler object and uses IPython.core.display.display_html to display these.
When I run this in addon mode, it works perfectly.
However, I would prefer to share this via an organiser topic. I have seen other topics here where images are updated and I have tried similar methods. This pushes the tables fine but loses the styling.
Is there a way to provide this styling to the organiser topic or perhaps the best approach might be to try to create images from the html?
Thanks.
-
Thanks Joanna
-
I have configured an Organiser Topic to update daily and send an email notification with attached PDF.
This is all working well, except it always creates the PDF in Portrait and I want it in landscape.
Is there a way for me to change this (R60.1.3-v202304242300) or does it need to be added as a feature request?
Thanks.
-
Thanks Thorsten.
We are currently using R56, but good to know this is fixed.
-
Hi,
I have a String signal that is having its label truncated on the y-axis.
Is there any way to widen the area for these labels to avoid this?
In case this doesn't make sense, hopefully this image will help:
Thanks.
-
Thanks very much Patrick.
I downgraded tzlocal to v2.1 and the issue is resolved.
- 1
-
I am investigating the Spy module on my local machine.
Following the example to pull data for a signal works when I give a timezone.
When I try to run throught the example in the spy.assets notebook, I run into an error at the
spy.push(metadata=build_df, errors='catalog')
stage. It throws an error:
AttributeError: 'NoneType' object has no attribute 'total_seconds'
This was the error that caused me to add timezones to the signal request, but I don't see how to do this for this request.
Any ideas?
Thanks.
-
Hi, I have a similar issue. Just wondering if you found a solution here?
-
Hi Joe,
thanks for the quick response.
That works perfectly!
-
Hi,
I want to create a capsule containing the 12 months previous to the current month. So, with today being 25th November, the capsule should be from 1st November 2019 00:00 to 1st November 2020 00:00.
I tried:
$startofthismonth = floorTime(now(), 1mo, '2020-11-01' ,"Europe/Belfast") $startofprevious12months = $startofthismonth - 12month condition(12 mo, capsule($startofprevious12months,$startofthismonth))
Which starts at the right time but shows 'In Progress'. Is there any way to do this so that the capsule has a proper end time.
The goal is to use this in an organiser topic to show 12 months data.
Perhaps there is a better way to do this?
Thanks.
Requesting advice on building Asset Tree & Analysis using TDD principles
in Seeq Data Lab
Posted
Hi all,
I have built an analysis on an asset tree and an SDL program that is becoming widely used and important for my colleagues.
Usually, I would try to build such a tool using Test Driven Development. Years of experience of breaking things has taught me the benefits of this approach!
However, I am struggling to build a strategy here and was wondering if there are any recommendations for doing this with the spy library.
Thanks.