How to change in Python Pandas the type of numerical data in one or more columns?

0

Using Python 3.4 and pandas = 0.19.2, perform a script in which you change the data type to a data column in the dataFrame. Using this version of pandas had a line of code with

pd.lib.infer_dtype

In my previous question I was recommended to update the panda version and change the instruction by:

prod.apply(lambda x: pd.api.types.infer_dtype(x.values)).

However, when I changed the version of Python to the newest one and the version of pandas to 0.22, several problems with my code began to appear between them:

When importing the datetime library in the following way:

from datetime import datetime 

My PyQt5 Calendar Widget closes unexpectedly when I click on a date

and another error is that when wanting to change the format of a column of cells to numeric simply ignores these lines of code and no longer responds.

lista1 = lista1.rename(columns = {'indice_planta':'planta','producto1':'producto', 'cajas_prod1': 'cajas','lbs_prod1': 'lbs', 'vel_producto1': 'velocidad', 'tprod1': 'tipo', 'resto1':'resto' })
lista1[['cajas','velocidad','lbs']] = lista1[['cajas','velocidad','lbs']].apply(pd.to_numeric)

(in the previous version of Python and Pandas I did not have this problem)

Another thing that I have noticed is that the console no longer shows me the errors that are presented, only it does not do anything

I have the full script on GitHub at the following link:

link and the file is /analisis_prod.py

I hope you can help me to tell me what I have to do to avoid these problems, the change of version has complicated things for me.

    
asked by Alejandro Gomez 19.01.2018 в 01:21
source

0 answers