Escenario:
fig.show() de Plotly no funciona en jupyter
Solución:
Forzar el renderizado agregando esta línea justo antes del fig.show() con pio
Ejemplo:
import plotly.io as pio
pio.renderers.default = 'iframe'
fig.show()
Listo!
Blog en espanol destinado a diferentes temas tecnicos principalmente en IT y Networking. Se desea cubrir Linux, DNS, DNSSEC, RPKI, BGP, Cisco, Programacion (Bash, Python, etc), Protocolos de Enrutamiento, Seguridad en Redes, VoIP.
Escenario:
fig.show() de Plotly no funciona en jupyter
Solución:
Forzar el renderizado agregando esta línea justo antes del fig.show() con pio
Ejemplo:
import plotly.io as pio
pio.renderers.default = 'iframe'
fig.show()
Listo!
¿Te gusta jugar dominó en parejas?
Si es así, te invito a conocer mi nuevo blog Simulación 1‑6‑8. En él combino la diversión del dominó con la potencia de la simulación en Python 3, todo ejecutado en Google Colab y apoyado por IA y estadística.
Generalmente hacemos 168 simulaciones para diversos escenarios y te mostramos los resultados de una manera sencilla y entendible. No te pierdas ningún post y aprende desde ya en: https://simulacion168.acostasite.com/
Situación:
Leyendo un archivo en python3 de texto (csv o txt) hay un carácter que se puede "apreciar" utilizando "more" en terminal pero en python3 es más complicada la situación.
Ejemplo 1:
$ more epa.csv
<U+FEFF>el texto
En mi caso, el archivo lo generé utilizando Excel y grabando como csv.
Ejemplo 2:
Problema:
Python3 lee el archivo bien, no arroja error pero ese "carácter" invisible queda en las variables, los textos, etc y puede traer algún inconveniente.
Solución:
La solución es leer el archivo y especificar el encoding, algo tan sencillo como:
FILENAME="epa.csv"
with open(FILENAME, encoding='utf-8-sig') as file:
for line in file:
print (line)
Explicación (tomado de: https://stackoverflow.com/questions/17912307/u-ufeff-in-python-string):
The Unicode character U+FEFF is the byte order mark, or BOM, and is used to tell the difference between big- and little-endian UTF-16 encoding.
Espero te haya ayudado
#!/usr/bin/python3.3
#The objetive of this script is to find all tables in a MYSQL DB and opmitize all of them
import dbconnect
import time
from datetime import datetime
## // VARIABLE DECLARATION ##//
startTime = datetime.now()
conn = dbconnect.dbconnect()
conn.autocommit(True)
cur = conn.cursor()
print ("Starting time: ", startTime)
SQLQUERY=("SHOW TABLES") #Find every table in the DB
cur.execute(SQLQUERY)
tables = cur.fetchall()
if len(tables)>0: #Prevent there are not tables in the list
for table in tables: #For every table in the DB
try:
SQLQUERY="OPTIMIZE TABLE "+ table[0] #Construct the SQL QUERY
print (" Optimizing", table[0])
cur.execute(SQLQUERY)
except:
pass
print ("Script execution time:",datetime.now()-startTime)
print ("Ending time: ", datetime.now())
print ("******** ****** ")
(seguramente hay más maneras más de hacer esto, incluso más elegantes pero así lo hice yo)
Escenario: fig.show() de Plotly no funciona en jupyter Solución : Forzar el renderizado agregando esta línea justo antes del fig.show() ...