Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Dataframe docs update #693

Merged
merged 10 commits into from
Jan 3, 2025

Conversation

AccordionGuy
Copy link
Contributor

Here’s the first of many rapid updates to the documentation for DataFrame. This one covers displaying DataFrames and the methods for the EditableDataframe class.

Copy link
Collaborator

@madeindjs madeindjs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 💪 I spotted some small mistakes, but it should be good.

docs/framework/dataframe.mdx Outdated Show resolved Hide resolved
docs/framework/dataframe.mdx Outdated Show resolved Hide resolved
docs/framework/dataframe.mdx Outdated Show resolved Hide resolved
})
```

```sh Polars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```sh Polars
```python Polars

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ ➕

})
```

```sh List of dictionaries
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```sh List of dictionaries
```python List of dictionaries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ ➕

docs/framework/dataframe.mdx Outdated Show resolved Hide resolved

A editable DataFrame is one whose content can change. Like static DataFrames, editable DataFrames use the **DataFrame** UI component. Unlike static tables, the DataFrame UI component is bound to an instance of `EditableDataframe`, a class provided by the Writer library. Changes to a `EditableDataframe` object will be immediately reflected in the DataFrame UI component that it is bound to.

<Note>Note that the "f" in `EditableDataframe` is _not_ capitalized — it’s `EditableDataframe`, not `EditableDataFrame`!</Note>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FabienArcellier @madeindjs can we change to standard capitalization of DataFrame? (I find it weird too, but it is what it is)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samjulien @ajot @AccordionGuy in general, if you find yourself writing something like this, please provide feedback and we'll likely fix it on our end 😀

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can. I have used the class name of pandas. Dataframe or dataframe looks better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you'll change from EditableDataframe to EditableDataFrame?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, bad reading for my comment on github. Ok for me to go to EditableDataFrame.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AccordionGuy we'll fix this on our end, can you please change docs to EditableDataFrame and remove the <Note>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramedina86 @FabienArcellier I've made the updates as requested and will let you folks know if I find potential issues like the capitalization of EditableDataframe — I figured that there might be a good reason for the original capitalization, but I’ll ask next time!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AccordionGuy 🙏🏻

@ramedina86 ramedina86 changed the title Dataframe docs update docs: Dataframe docs update Dec 16, 2024
@ramedina86 ramedina86 marked this pull request as draft December 17, 2024 12:57
Copy link
Contributor

@samjulien samjulien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few corrections needed and a little intro and conclusion cleanup

## Use a dataframe

**a dataframe is simply added to the state**. A component like `dataframe` will be able to display it.
**Writer Framework has two objects with the name _DataFrame_:**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an intro sentence here to help people understand what they're trying to accomplish with dataframes?

The call to `wf.init_state()` adds the `DataFrame` to the application's `state` variable as the value of the `mydf` key.
</Step>
<Step title="Add a DataFrame component to the UI and bind it to the DataFrame data structure">
Add a DataFrame UI component to the user interface, then set its **Data** property to `@{`_dataframe_key_`}`, where _dataframe_key_ is the `state` variable key whose value refers to the `DataFrame` data structure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underscores at the front and end of _dataframe_key_ add italics and break the code formatting, I'd remove them.


In the case of this example, `mydf` is the `state` variable key referring to the `DataFrame`, so set the **Data** property to `@{mydf}`.

![DataFrame for static table example with properties panel open](images/dataframe_static_table_1.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image is broken for me, might want to double check the URL against other docs. I think you need to add /framework to the front possibly but check out other examples.

})
```

```sh Polars
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ ➕

})
```

```sh List of dictionaries
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

☝️ ➕


In the case of this example, `mydf` is the `state` variable key referring to the `DataFrame`, so set the **Data** property to `@{mydf}`.

![DataFrame for dynamic table example with properties panel open](images/dataframe_dynamic_table_1.png)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on image URL being broken

})
```
```python
state["mydf"].record_remove({"record_index": 2})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is missing a conclusion or something to wrap this up and tell the user where to go next

To present a data table in Writer Framework, you create a `DataFrame` data structure in your code and then bind it to a UI Dataframe.


## Displaying a static DataFrame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please briefly discuss the options in the DataFrame component (e.g. sorting, downloading, searching) and link to the component documentation.

@samjulien
Copy link
Contributor

Updates look great @AccordionGuy! @ramedina86 @FabienArcellier this is ready for you all to review and merge! Once that's done we'll need to update the main mintlify.json in the docs repo -- happy to do it unless you already have that as part of your process, I know Fabien was looking at automating this.

@samjulien
Copy link
Contributor

@FabienArcellier just bumping this for visibility once you're back from the holidays. Would love to finally get Dataframe documented! Thank you!

@FabienArcellier
Copy link
Collaborator

FabienArcellier commented Jan 3, 2025

I review and fix conflicts. It looks ok. I would advocate to explain on how to use record_add, record_update and record_remove in event handler (maybe screenshot or small video). This method are design to be compliant with event handler payload.

# Subscribe this event handler to the `wf-dataframe-add` event
#
# more on : https://dev.writer.com/framework/dataframe
def on_record_add(state, payload):
	payload['record']['sales'] = 0 # default value inside the dataframe
	state['mydf'].record_add(payload) # should contain an EditableDataFrame instance

@samjulien if it looks ok for you, I will merge. Let me know

@FabienArcellier FabienArcellier marked this pull request as ready for review January 3, 2025 17:25
@FabienArcellier
Copy link
Collaborator

@samjulien I haven't work on the topic of automatic table of content generation. It would focus on generated contents (components and later on workflow blocks), not on editorialized pages as Dataframe or ai-modules.

@samjulien
Copy link
Contributor

Thanks @FabienArcellier! Let's go ahead with this -- I've added a Jira ticket to the Docs & DX board for making your suggested updates in the next iteration of this doc. Whenever it's released I'll manually add to the main Mintlify nav in the docs repo.

@FabienArcellier FabienArcellier merged commit 7b34e51 into writer:dev Jan 3, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants