How to format string in a Pandas DataFrame Column?
0

How to format string in a Pandas DataFrame Column?

This recipe helps you format string in a Pandas DataFrame Column

In [1]:
## How to format string in a Pandas DataFrame Column
def Kickstarter_Example_98():
    print()
    print(format('How to format string in a Pandas DataFrame Column','*^82'))

    import warnings
    warnings.filterwarnings("ignore")

    # load libraries
    import pandas as pd

    # Create a list of first names
    first_names = pd.Series(['Steve Murrey', 'Jane Fonda',
                             'Sara McGully', 'Mary Jane'])
    print()
    print(first_names)

    # print the column with lower case
    print(); print(first_names.str.lower())

    # print the column with upper case
    print(); print(first_names.str.upper())

    # print the column with title case
    print(); print(first_names.str.title())

    # print the column split across spaces
    print(); print(first_names.str.split(" "))

    # print the column with capitalized case
    print(); print(first_names.str.capitalize())

Kickstarter_Example_98()
****************How to format string in a Pandas DataFrame Column*****************

0    Steve Murrey
1      Jane Fonda
2    Sara McGully
3       Mary Jane
dtype: object

0    steve murrey
1      jane fonda
2    sara mcgully
3       mary jane
dtype: object

0    STEVE MURREY
1      JANE FONDA
2    SARA MCGULLY
3       MARY JANE
dtype: object

0    Steve Murrey
1      Jane Fonda
2    Sara Mcgully
3       Mary Jane
dtype: object

0    [Steve, Murrey]
1      [Jane, Fonda]
2    [Sara, McGully]
3       [Mary, Jane]
dtype: object

0    Steve murrey
1      Jane fonda
2    Sara mcgully
3       Mary jane
dtype: object

Relevant Projects

Big Data Project Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.
Big Data Project Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.
Big Data Project Data Science Project-All State Insurance Claims Severity Prediction
Data science project in R to develop automated methods for predicting the cost and severity of insurance claims.
Big Data Project Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.
Big Data Project Predict Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.
Big Data Project Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.
Big Data Project Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.
Big Data Project Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.
Big Data Project Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.
Big Data Project Music Recommendation System Project using Python and R
Machine Learning Project - Work with KKBOX's Music Recommendation System dataset to build the best music recommendation engine.