Replacing Pandas or Numpy Nan with a None to use with MysqlDB

@bogatron has it right, you can use where, it’s worth noting that you can do this natively in pandas: Note: this changes the dtype of all columns to object. Example: Note: what you cannot do recast the DataFrames dtype to allow all datatypes types, using astype, and then the DataFrame fillna method: Unfortunately neither this, nor using replace, works with None see this (closed) issue. As an aside, … Read more

Read data (.dat file) with Pandas

You can use parameter usecols with order of columns: Edit: You can use separator regex – 2 and more spaces and then add engine=’python’ because warning: ParserWarning: Falling back to the ‘python’ engine because the ‘c’ engine does not support regex separators (separators > 1 char and different from ‘\s+’ are interpreted as regex); you … Read more

Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support

I am trying to read a .xlsx with pandas, but get the follwing error: I’ve also tried And I Still get the same error. Background: I’m trying to extract an excel file with multiple worksheets as a dict of data frames.I installed xlrd version 0.9.0 and the latest version(1.1.0) but I still get the same … Read more

cannot convert the series to

Your error is line 2. df[‘intage’] = int(df[‘age’]) is not valid, you can’t pass a pandas series to the int function. You need to use astype if df[‘age’] is object dtype. Or since you are subtracting two dates, you need to use dt accessor with the days attribute to get the number of days as … Read more