@EdChum’s answer is clever and works well. But since there’s more than one way to bake a cake…. why not use regex? For example:
df[df.columns[1:]] = df[df.columns[1:]].replace('[\$,]', '', regex=True).astype(float)
To me, that is a little bit more readable.
More Related Contents:
- Python returns "SyntaxError: invalid syntax sys module" [closed]
- How to write to an existing excel file without overwriting data (using pandas)?
- How to sort a dataFrame in python pandas by two or more columns?
- How to display pandas DataFrame of floats using a format string for columns?
- Why isn’t my Pandas ‘apply’ function referencing multiple columns working? [closed]
- Reading an Excel file in python using pandas
- How do I create test and train samples from one dataframe with pandas?
- How to map numeric data into categories / bins in Pandas dataframe
- Check if a string in a Pandas DataFrame column is in a list of strings
- Naturally sorting Pandas DataFrame
- Convert timedelta64[ns] column to seconds in Python Pandas DataFrame
- How to normalize json correctly by Python Pandas
- Insert a Pandas Dataframe into mongodb using PyMongo
- Improve Row Append Performance On Pandas DataFrames
- Comparing two pandas dataframes for differences
- Use Multiple Character Delimiter in Python Pandas read_csv
- Merging dataframes based on date range
- pandas: replace string with another string
- how to merge two data frames based on particular column in pandas python?
- How to solve import error for pandas?
- I want to multiply two columns in a pandas DataFrame and add the result into a new column
- pandas, melt, unmelt preserve index
- Parse a Pandas column to Datetime when importing table from SQL database and filtering rows by date
- Python Pandas – Read csv file containing multiple tables
- Group DataFrame in 5-minute intervals
- Python Pandas add column for row-wise max value of selected columns [duplicate]
- Python Pandas: remove entries based on the number of occurrences
- How to filter a DataFrame column of lists for those that contain a certain item
- Read .doc file with python
- How to slice a pandas DataFrame by position?