AgGrid in Python giving blank grid when run with Justpy to display a Dataframe on the webpage.
Please find below the python code I am trying to run... It is giving a blank grid can you please help me debug???
import pandas as pd
import justpy as jp
w1=pd.DataFrame([[1,2,3],[2,3,4],[3,4,5]])
def grid_test():
print(w1)
wp = jp.WebPage()
jp.Strong(text=str(w1), a=wp)
grid = jp.AgGrid(a=wp)
grid.load_pandas_frame(w1)
return wp
jp.justpy(grid_test)
Does the example described in https://justpy.io/grids_tutorial/pandas/ work for you?
I encountered the same issue. The issue for me resolved when I made certain the recordset contained no null values. My orignal recordset had some null values.
Related
I'm using st.write() to display a dataframe with long strings in a column. When i display the dataframe with st.write(df) it does not show all info, here is an example:
Here is the code:
with st.container():
st.write('<style>div[data-baseweb="table"] .cell {white-space: pre-wrap;}</style>',
unsafe_allow_html=True)
st.dataframe(df_observaciones, width=1500, height=450)
I want to see all the info and include line breaks if necesary, any help will be good.
One easy option is to use st.table(df), shows all the info.
https://docs.streamlit.io/library/api-reference/data/st.table
st.table(df)
I have an excel sheet with data I'd like to input into boxes on a web form.
import pandas as pd
df = pd.read_excel('C:\\Users\\jj\\Documents\\python_date_test.xlsx', Sheet_name=0)
(df['bx1'][0])
The output of the above code is '2'
When I insert this code into the code I'm using to webcrawl, I get the following error 'TypeError: object of type 'numpy.int64' has no len()'
Here's the code that produced this error:
mea1 = browser.find_element_by_name("data1_14581")
mea1.click()
mea1.send_keys((df['bx1'][0]))
mea1.send_keys(Keys.TAB)
mea1 refers to the first box for user input.
How can I get the value of (df['bx1'][0]) and enter it in to the box?
I haven't used this package but looking at it I believe you are on the right track, try changing the code to:
mea1.send_keys(str((df['bx1'][0])))
We are currently working on a project where we need to access the 'NP_' accession number from ClinVar. However, when we use the Entrez.eFetch( ) function, this information appears to be missing in the result. Here is a link to the website page where the NP_ number is listed:
https://www.ncbi.nlm.nih.gov/clinvar/variation/558834/
And here is the Python sample script code that fetches the XML result:
handle = Entrez.efetch(db="clinvar", id=558834, rettype='variation', retmode="text")
print(handle.read())
Interestingly enough, this used to return the NP number in the results, however, it seems to the website formatting/style changed from when we last developed our Python script and we cannot seem to figure out how to retrieve the NP number now.
Any help would be greatly appreciated! Thank you for your time and input!
You need to format it like a new query not an old one:
handle = Entrez.efetch(db="clinvar", id=558834, rettype='vcv', is_varationid="true", from_esearch="true")
print(handle.read())
See also: https://www.ncbi.nlm.nih.gov/clinvar/docs/maintenance_use/
I can't seem to find a way to change the length f the entire table in a word-document. I have only seen examples of ways to change the columns in the table, not the actual table itself.
Would be great if someone could tell me how to do it :)
Here is my code:
from docx import Document
document = Document()
table = document.add_table(rows=4, cols=2)
table.style = 'Table Grid'
The Table class has methods to add rows.
https://python-docx.readthedocs.io/en/latest/api/table.html#docx.table.Table.add_row
Found a solution to my problem. I got this from ANOTHER user here # stack. Can't seem to find the link tho....
The original code is NOT mine, I only modified it a little.
def ChangeWidthOfTable(table,width,column):
for columnVarible in range(0,column):
for cell in table.columns[columnVarible].cells:
cell.width = Cm(width)
I have looked into many stackoverflow questions but none of them seemed to solve my problem. I am using Python and Openpyxl to fill a whole row with red given a certain condition. I did all the importations necessary :
from openpyxl.styles import PatternFill, NamedStyle, Color
from openpyxl.styles.colors import RED
And my code is the following :
for cell in sheet[i]:
cell.style = NamedStyle(fill=PatternFill(patternType='solid',
fill_type='solid',
fgColor=Color(RED)))
When I ask to print the first occurence of cell it gives me
<Cell 'Divers'.A4>
which is what I am looking for.
However, the following error comes every time : "Style Normal exists already". There is absolutely no cell formatting or style whatsoever in the rest of the code but the Excel file cells are indeed filled with yellow already.
Any idea on how to solve this ? Thanks in advance for any help.
If using a NamedStyle, you're required to pass a name.
red_foreground = NamedStyle(
name="RedForeground",
fill=PatternFill(
patternType='solid',
fill_type='solid',
fgColor=Color(RED)
)
)
Since you're assigning this NamedStyle to more than one cell, it makes sense to register it to your workbook.
wb.add_named_style(red_foreground)
Then you can update it's application to cells, like so:
for cell in sheet[i]:
cell.style = "RedForeground"
Reference:
Creating NamedStyle
NamedStyle Constructor
I also have this problem, and finally found that it was because there were 2 styles, of which had the same name. This is usually caused when you use copy.copy(style). Then after change one of the style.name = 'newname', it will work.
This code would solve already existing named styles.
for index,cur_style in enumerate(excel_workbook._named_styles):
if cur_style.name == 'my_new_style':
excel_workbook._named_styles[index] = my_new_style
my_new_style.bind(excel_workbook)
break
else:
excel_workbook.add_named_style(my_new_style)
However, in your case, you should use some other name than "Normal", because "Normal" is the default named style, just find another name and you can use the code I pasted
There is another way to solve traceback by adding existing styles:
if not 'Style_A' in wb.named_styles:
wb.add_named_style(Style_A)