Cesar Rodriguez
Cesar Rodriguez

Reputation: 192

Kivy Display Data from pandas to Kivy

i have some data ready to be display from a pandas database, i would like to make it look good but i was just able to print it as a label. and looks awful. also i would like to make it scrolldable but i totally new in Kivy. I haven't able to make work any of the solution on the internet. this is my code.

I was hoping there is some kind of library that will handles pandas to Kivy but i don't see nothing like that.

any suggestion will be appreciated thank you in advance.

class ScatterTextWidget(BoxLayout):

''' this part we take the information from timestation website and start analyze it '''

    item_to_display = ObjectProperty()
    text_location = ObjectProperty()
    input_date = ObjectProperty()
    input_time = ObjectProperty()

    def initialize_request(self):
        ''' Initial analysis and control flow of the class '''

        location = self.text_location.text
        date = self.input_date.text
        time_raw = self.input_time.text

        url = 'test.csv'

        data = pd.read_csv(url)
        time = self.time_format_checker(time_d=time_raw)
        group_name = data[data["Time"] <= time]
        duplicates_removed = group_name.drop_duplicates(subset="Name", keep='last')
        punch_in_df = duplicates_removed[duplicates_removed.Activity.str.contains('Punch In')]
        filtered_data = punch_in_df[punch_in_df.Department.str.contains(location)]
        filtered_data.reset_index(inplace=True)
        self.item_to_display.text = filtered_data[['Name', 'Department', 'Device', 'Time']].to_string()

this is the kivy file --- Short version :

#:import utils kivy.utils
#:import ListAdapter kivy.adapters.listadapter.ListAdapter
#:import ListItemButton kivy.uix.listview.ListItemButton
#:import main MainGui


<ScatterTextWidget>:

    text_location:text_location
    item_to_display:item_to_display
    input_date:input_date
    input_time:input_time


    canvas.before:
        Color:
             rgb: utils.get_color_from_hex('#000131')
        Rectangle:
            pos: self.pos
            size: self.size

    BoxLayout:
         orientation: "vertical"

        BoxLayout:
            canvas.before:
                 Color:
                    rgb: utils.get_color_from_hex('#00050c')
                 Rectangle:
                    pos: self.pos
                    size: self.size

            Label:
                id:item_to_display
                pos_hint_y: 'top'
                size_hint_y: .75
                text: 'Please introduce the Date'

I hope to get something thing like this:

Name               | Department   | Device      | Time |
Rodriguez, Cesar   |IT Department | IT Office   | 6:00 |
Clarke, Gyles      |Kent Avenue   | Kent Device | 7:00 |

Upvotes: 4

Views: 3064

Answers (1)

Hiadore
Hiadore

Reputation: 714

Have you check this module DataframeGUIKivy ?

You can display pandas dataframe in Kivy using this module.

Upvotes: 3

Related Questions