Как мне получить таблицу bokeh
для сортировки столбца по значению с плавающей запятой вместо строкового значения? У меня есть данные с плавающей запятой, которые столбец продолжает сортировать как строку, поэтому он не сортируется должным образом в порядке возрастания / убывания. Данные и фрагмент кода прилагаются.
Данные:
GB, 15.789, /path/to/A, size, 100.0
GB, 600.123, /path/to/B, size, 100.0
GB, 70.456, /path/to/C, size, 100.0
Отрывок:
#!/usr/bin/env python3
from bokeh.io import output_file, show, save
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, DateFormatter, TableColumn, NumberFormatter
def get_data():
lines = open('json.tmp', 'r').read().splitlines()
data = {
'unit': [],
'value': [],
'location': [],
'type': [],
'tol': [],
}
for line in lines:
words = line.split(',')
data['unit'].append(words[0])
data['value'].append(words[1])
data['location'].append(words[2])
data['type'].append(words[3])
data['tol'].append(words[4])
return data
if __name__ == "__main__":
data = get_data()
output_file("data_table.html")
source = ColumnDataSource(data)
columns = [
TableColumn(field="location", title="Path"),
TableColumn(field="value", title="Value", formatter=NumberFormatter(format="0.0")),
TableColumn(field="unit", title="Unit", width=10),
TableColumn(field="type", title="Type", width=20)
]
data_table = DataTable(source=source, columns=columns)
save(data_table)