-
Notifications
You must be signed in to change notification settings - Fork 114
Description
When having a numeric column in a dataframe, the default for sorting seems to be to have negative values sorted, then np.nan or none values, then positive values. I get this is default behavior in pandas, but it makes the dataframes a bit cumbersome to view when I have some columns with a lot of blank values but also negative and positive values (big gap between my populated data). However, I don't want to filter the entire row out, since other columns of that row do have valid values.
The update_sort you added allows for sorting by multiple columns with buttons, but doesn't change the underlying behavior of the sort.
Is there any way to add an argument, such as na_position=last, so that blank values can go to the end?
Here is a basic example to illustrate what I am asking:
from shiny import App, render, ui
import pandas as pd
import numpy as np
data = {
'ID': range(1, 11),
'Name': ['Item ' + str(i) for i in range(1, 11)],
'Value': [10.5, -5.2, np.nan, 15.7, -8.3, np.nan, 22.1, -12.4, 7.8, -3.9]
}
df = pd.DataFrame(data)
app_ui = ui.page_fluid(
ui.h2("Data Grid Example"),
ui.card(
ui.output_data_frame("grid")
)
)
def server(input, output, session):
@output
@render.data_frame
def grid():
return render.DataGrid(df)
app = App(app_ui, server) In this example, the sort will look like this:
However, ideally, I'd like the na_position=last option so the blanks would be at the end
