[PYTHON] Convert comma-separated numeric strings to numbers in Pandas DataFrame

Introduction

I wanted to change a string separated by commas every 3 digits to a number, such as 25,000 in Pandas DataFrame.

code

df.apply(lambda x: x.str.replace(',','')).astype(np.int)

Reference page

pandas – some ways to replace part of a string.

Thank you very much. If there is another way, I would appreciate it if you could teach me.

Recommended Posts

Convert comma-separated numeric strings to numbers in Pandas DataFrame
Convert numeric variables to categorical with thresholds in pandas
How to reassign index in pandas dataframe
Convert pandas dataframe elements to regular string type
Convert 202003 to 2020-03 with pandas
How to convert floating point numbers to binary numbers in Python
[Python] Convert list to Pandas [Pandas]
Export pandas dataframe to excel
Convert from Pandas DataFrame to System.Data.DataTable using Python for .NET
Put the lists together in pandas to make a DataFrame
A handy function to add a column anywhere in a Pandas DataFrame
Convert markdown to PDF in Python
How to write soberly in pandas
Convert list to DataFrame with python
How to convert 0.5 to 1056964608 in one shot
[Python] Convert natural numbers to ordinal numbers
Convert decimal numbers to n-ary numbers [python]
How to get a specific column name and index name in pandas DataFrame
How to convert csv to tsv in CLI
Convert character strings to features with RoBERTa
Use pandas to convert grid data to row-holding (?) Data
[Pandas] Expand the character string to DataFrame
[Python] Pandas to fully understand in 10 minutes
[Python] Add total rows to Pandas DataFrame
How to convert DateTimeField format in Django
Convert from Markdown to HTML in Python
How to read CSV files in Pandas
Adding Series to columns in python pandas
Convert absolute URLs to relative URLs in Python
Is there NaN in the pandas DataFrame?
[Python learning part 3] Convert pandas DataFrame, Series, and standard List to each other
3 ways to parse time strings in python [Note]
Convert FBX files to ASCII <-> BINARY in Python
Convert PDFs to images in bulk with Python
[python] Create table from pandas DataFrame to postgres
Delete rows with arbitrary values in pandas DataFrame
Convert UTF-8 CSV files to read in Excel
Batch convert PSD files in directory to PDF
Remove rows with duplicate indexes in pandas DataFrame
Save Pandas DataFrame as .csv.gz in Amazon S3
Convert exponential notation float to str in Python
How to count numbers in a specific range
Add totals to rows and columns in pandas
Convert cubic mesh code to WKT in Python
Convert strings to character-by-character list format with python