Pandas with numpy array

Heads up! You've already completed this tutorial.

friedhelm | 2021-04-14 14:14:00 UTC | #1

It is the first time ask a question here. :thinking:

How could I handle a cell in the QAbstactTableModel with an numpy array/list?

Thanks and regards friedhelm


martin | 2021-04-14 17:42:06 UTC | #2

Hi @friedhelm welcome to the forum!

There is an example of using numpy arrays with a custom table model in the book (under the Model Views chapter) and also a tutorial on the site here.

If that's not what you're looking for, can you give a bit more detail of the problem?


friedhelm | 2021-04-14 18:37:32 UTC | #3

Hi @martin thank you for the answer!

I mean this more in a scientist view, if you know PyTables this is the question in the direction of subarrays in QTableCell or a pandas Table in a QTableCell.

Is a PyTables hierachical tree like structure to handle in QT?

Thanks and regards


friedhelm | 2021-04-20 14:20:23 UTC | #4

Hi @martin sorry for the late answer,

here is a sample:

series_and_table|631x330

This are only a short sample, the real table or series are in the range of 800 to 2000 values. Further 100 - 200 Item with series or tables.

My Interest is to select/load Series/Tables and find min/max values or mean values, ... , the Delegate must a list for a Series or an QTableView....?


martin | 2021-04-23 08:42:41 UTC | #5

Thanks @friedhelm -- it depends a bit on what you want to accomplish, whether you want to be able to edit these fields or just display summary info?

Editing

The short answer is no there isn't a built in widget that can handle this, but it should be possible to create something. The normal way to handle this I think would be to have a 2nd table view either adjacent in the UI or able to pop up as an editor.

In the model view of the view in your screenshot, we would show a simple "summary" view (truncated or dimensions) and then based on an interaction, e.g. double-clicking, pop out the table editor for that cell.

Summary data (min/max)

If you want to load a table somehow and then just display summary data, you can do that. In a .data() method you can return anything you want for a given cell, so could just return min(table) to display that. But that will get pretty slow. What I would do instead is do the analysis of the table when the data is set, and store that data in some kind of structure in the model. You can then recalculate if the data changes.

Let me know what you're looking for and I can put together a small example.


friedhelm | 2021-04-23 10:43:07 UTC | #6

Thanks @martin for this overview and the informativ hint‘s.

Thanks and best Regards friedhelm


The complete guide to packaging Python GUI applications with PyInstaller.
[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Pandas with numpy array was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.