Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
assign dtype with from_dict

I have data in a python dictionary like:

data = {u'01-01-2017 22:34:43:871': [u'88.49197', u'valid'],
        u'01-01-2017 11:23:43:803': [u'88.49486', u'valid'],
        u'02-01-2017 03:11:43:898': [u'88.49773', u'valid'],
        u'01-01-2017 13:54:43:819': [u'88.50205', u'valid']}

I can convert it to a pandas Dataframe with:

data = pandas.DataFrame.from_dict(data, orient='index')

but I am not able to use the dtype parameter of from_dict. I would convert the index to a datetime of similar first column to float and third to string.

I have tried:

pandas.DataFrame.from_dict((data.values()[0]), orient='index', 
                                               dtype={0: 'float', 1:'str'})

but it doesn't work.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This appears to be an ongoing issue with some of the pandas constructor methods: How to set dtypes by column in pandas DataFrame

Instead of using the dtype argument, chaining .astype may do the trick:

pandas.DataFrame.from_dict(data, orient='index').astype({0: float, 1:str})
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda