
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find Length of Words in a Pandas Series
In this task, we will find the length of strings in a Pandas series. We will use the str.len() function in the Pandas library for this purpose.
Algorithm
Step 1: Define a Pandas series of string. Step 2: Find the length of each string using the str.len() function. Step 3: Print the results.
Example Code
import pandas as pd series = pd.Series(["Foo", "bar", "London", "Quarantine"]) print("Series: \n", series) length = series.str.len() print("Length:\n", length)
Output
Series: 0 Foo 1 bar 2 London 3 Quarantine dtype: object Length: 0 3 1 3 2 6 3 10 dtype: int64
Advertisements