0

I have a dataset and perform kaplan meier analysis on it using lifelines library, I then perform log rank and cox analysis, but the output i receieve are type 'statistical result' I would live to display this on a GUI but cannot figure it out.

  • This is very generic. there are a number of GUI's available as well as a number of other methods (excel / pdf / web). Do you have something specific in mind, or what have you tried so far ? – D.L Feb 24 '22 at 14:56
  • My GUI is on python tkinter,but put this aside for a second, I perform the logrank analysis on my data and achieve a statistical result, its not an image, data frame or anything that I am able to download but rather just type 'statistical result' I need to display this on my GUI and not just in the python command line. – Jacob Mendelowitz Feb 24 '22 at 15:38
  • what do you mean `"statistical result"` ? If you means text then you can use `Label` or `Textbox` to display it. If you means some data in rows and columns then you could use `grid()` to put `Labels` in rows and columns. – furas Feb 24 '22 at 19:17
  • The lifelines library has a type called 'statistical result' – Jacob Mendelowitz Feb 27 '22 at 10:57
  • @JacobMendelowitz you can access the properties of the `StatisticalResult` with a `.`. `result.p_value` for example – Cam.Davidson.Pilon Feb 27 '22 at 14:26

1 Answers1

0

You can save the data as a csv file.

From this, a (or any) package like tkinter can read the CSV.

Here is a stackoverflow link to such:

How to show csv file in a grid?

And here is an example of the code:

import tkinter
import csv

root = tkinter.Tk()

# open file
with open("test.csv", newline = "") as file:
   reader = csv.reader(file)

   # r and c tell us where to grid the labels
   r = 0
   for col in reader:
      c = 0
      for row in col:
         # i've added some styling
         label = tkinter.Label(root, width = 10, height = 2, \
                               text = row, relief = tkinter.RIDGE)
         label.grid(row = r, column = c)
         c += 1
      r += 1

root.mainloop()

Obviously, you would need to apply your variant to this.

D.L
  • 4,339
  • 5
  • 22
  • 45