python_libre_pythonista_ext icon indicating copy to clipboard operation
python_libre_pythonista_ext copied to clipboard

Getting started headers do not seem to be respected

Open mwpowellhtx opened this issue 8 months ago • 3 comments

Perhaps I am doing something wrong. Trying to run against Python 3, pip and pandas installed there. Possibly 2 runtime is interfering there I'm not sure, which pandas is probably not installed on pretty sure.

surveys_ctrl+c.ods

Following the brief intro to LO Pythonista, working to a point.

The source data in the spreadsheet for which I will start gathering some simple and gradually more elaborate metrics using Python, based on a Basic formula, in both the header as well as the data columns themselves.

Not sure what I am doing wrong here, or perhaps is not a great fit for it.

mwpowellhtx avatar May 07 '25 06:05 mwpowellhtx

At present, best guestimates on my part, headers cannot be formula calculated, rather must be static, in nature; which is fine. Not sure whether formula driven headers could otherwise be supported.

mwpowellhtx avatar May 07 '25 16:05 mwpowellhtx

Next thought on this journey... How do I convey, relay, whatever... I want to calculate some Pythonista, Pandas, or whatever, metrics if possible.

I have a Py cell calculating based on the <> DataFrame, not sure how to relay that as a proper card or whatever.

class Metrics:
    def __init__(self, x, y):
        s = self

        xmin = x.min()
        xmax = x.max()
        xmean = x.mean()

        ymin = y.min()
        ymax = y.max()
        ymean = y.mean()

        s.xmin = xmin
        s.xmax = xmax
        s.xmean = xmean
        s.xmid = xmin + (xmax - xmin) / 2

        s.ymin = ymin
        s.ymax = ymax
        s.ymean = ymean
        s.ymid = ymin + (ymax - ymin) / 2

    def data(self):
        s = self
        return [s.xmin, s.xmax, s.xmean, s.xmid, s.ymin, s.ymax, s.ymean, s.ymid]

met = Metrics(dt.x, dt.y)
met

mwpowellhtx avatar May 07 '25 17:05 mwpowellhtx

I looked at you sheet example. I see the issue. You are correct that Headers are being ignored. For now this is by design.

When a DataFrame is created LibrePythonista auto discovers if it has headers. Clearly in this case it is not detecting the headers correctly. I can see that when I view the Card view for the DataFrame. I will most likely have to implement headers=True to fix this issue. BTW 0.10.2 was released yesterday.

Amourspirit avatar May 23 '25 12:05 Amourspirit

This has been corrected in version 0.10.4. The Auto detect headers was updated. At this time headers=True in the lp() function are still ignored.

Amourspirit avatar May 30 '25 23:05 Amourspirit