Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting strings to a lower case in pandas [duplicate]

I have a data that contains domain names:

 url          var1 www.CNN.com   xsd www.Nbc.com   wer www.BBc.com   xyz www.fOX.com   zyx .... 

The data is of the Series type. I am using the following to convert url variable to lower case:

df.apply(lambda x: x.astype(str).str.lower()) 

However, they remain the same.

What am I doing wrong?

like image 508
Feyzi Bagirov Avatar asked Mar 12 '17 17:03

Feyzi Bagirov


People also ask

How do you convert a string into lowercase in python?

In Python, lower() is a built-in method used for string handling. The lower() method returns the lowercased string from the given string. It converts all uppercase characters to lowercase.

How would you convert a string into lowercase?

The toLowerCase() method converts a string to lower case letters.

How do you convert a lowercase to a series in Python?

lower. Convert strings in the Series/Index to lowercase. Equivalent to str.

How to lowercase a string in pandas Dataframe?

In this tutorial we will be using lower () function in pandas to convert the character column of the python pandas dataframe to lowercase. If the input string in any case (upper, lower or title) , lower () function in pandas converts the string to lower case.

How to convert string to lowercase in Python?

Convert strings in the Series/Index to lowercase. Equivalent to str.lower(). Returns Series or Index of object See also Series.str.lower Converts all characters to lowercase.

What does STR lower () do in pandas?

pandas.Series.str.lower¶ Series.str.lower()[source]¶ Convert strings in the Series/Index to lowercase. Equivalent to str.lower(). Returns Series or Index of object

How to convert uppercase string to lowercase in C++?

We used the tolower function within the loop to convert uppercase string to lowercase. The C++ has the std transform function under the algorithm file to convert uppercase string to lowercase. Please Enter the String to Convert into Lowercase = HELLo WolLD!


1 Answers

df['url'] = df['url'].str.lower() 

should operate on the series and replace it with the lower case version.

like image 150
David Avatar answered Sep 19 '22 05:09

David