April 19, 2020
Looking at Types
To see the types of each column of a DataFrame, we can use print(df.dtypes)
The data types Pandas uses are:
float
int
bool
datetime
timedelta
category
object
We can use what we know of regex to get rid of dollar signs:
fruit.prices = fruit[‘price’].replace(‘[\$,]’,’’,regex=True)
We can use the Pandas function .to_nameric( ) to convert strings containing numerical values to integers or floats:
fruit.price = pd.to_numeric(fruit.price)
To extract the numbers from a string, we can use Pandas .str.split( ) function:
split_df = df[‘exerciseDescription’].str_split(‘(\dt)’, expand = True)