- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Finding the length of words in a given 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
- Related Articles
- How to get the length, size, and shape of a series in Pandas?
- Finding the number of words in a string JavaScript
- Python - Find words greater than given length
- Finding words in a matrix in JavaScript
- Finding the length of a JavaScript object
- Finding duplicate "words" in a string - JavaScript
- Write a program in Python to find the maximum length of a string in a given Series
- Print the mean of a Pandas series
- Reversing the even length words of a string in JavaScript
- Accessing elements of a Pandas Series
- Finding the length of the diagonal of a cuboid using JavaScript
- Finding the length of second last word in a sentence in JavaScript
- Finding top three most occurring words in a string of text in JavaScript
- Finding n most frequent words from a sentence in JavaScript
- Finding the length of longest vowel substring in a string using JavaScript

Advertisements