Documenting the answer that worked for me based on the comment by @piRSquared.
I needed to convert to a string first, then an integer.
>>> df['purchase'].astype(str).astype(int)
More Related Contents:
- Replacing values represented by 'UN' with NaN
- Convert pandas dataframe to NumPy array
- Strings in a DataFrame, but dtype is object
- Performance of Pandas apply vs np.vectorize to create new column from existing columns
- What does axis in pandas mean?
- FutureWarning: elementwise comparison failed; returning scalar, but in the future will perform elementwise comparison
- pandas select from Dataframe using startswith
- How to map numeric data into categories / bins in Pandas dataframe
- What’s the fastest way in Python to calculate cosine similarity given sparse matrix data?
- Restart cumsum and get index if cumsum more than value
- How can I map True/False to 1/0 in a Pandas DataFrame?
- What does the term “broadcasting” mean in Pandas documentation?
- Dropping infinite values from dataframes in pandas?
- ValueError: numpy.dtype has the wrong size, try recompiling
- ‘DataFrame’ object has no attribute ‘sort’
- Pandas pd.Series.isin performance with set versus array
- Improve Row Append Performance On Pandas DataFrames
- Difference between data type ‘datetime64[ns]’ and ‘
- python pandas flatten a dataframe to a list
- Precision lost while using read_csv in pandas
- Get week start date (Monday) from a date column in Python (pandas)?
- What is dtype(‘O’), in pandas?
- pandas distinction between str and object types
- Normalize data in pandas
- NumPy version of “Exponential weighted moving average”, equivalent to pandas.ewm().mean()
- Python Pandas – Missing required dependencies [‘numpy’] 1
- Pandas: Difference between largest and smallest value within group
- How to use sklearn fit_transform with pandas and return dataframe instead of numpy array?
- mean from pandas and numpy differ
- Convert Pandas dataframe to Sparse Numpy Matrix directly