lowercase

pandas srt.lower() not working on dataframe column

自作多情 提交于 2019-12-02 01:29:09
问题 I'm working with the Titanic dataset available from Kaggle. I have it in a dataframe and i want to change the case of the "sex" column to lowercase. I'm using the following code import pandas as pd df = pd.read_csv('titanic.csv') print dfFull['sex'].unique() df.sex.str.lower() #check if it worked print df['sex'].unique() and also trying df['sex'].str.lower() but when I run df['sex'].unique() I get three unique values [male, female, Female] . Why does my code not lower the case of the strings

Python - replacing lower case letters

孤者浪人 提交于 2019-12-02 01:16:38
>>> import string >>> word = "hello." >>> word2 = word.replace(string.lowercase, '.') >>> print word2 hello. I just want all the lowercase letters to turn into full stops. What am I doing wrong here? Use a regular expression : from re import sub print sub("[a-z]", '.', "hello.") str.replace is looking for the string abcdefghijklmnopqrstuvwxyz to replace it with . , not looking for each individual letter to replace. you should use string.translate() : >>> import string >>> input = 'abcABCaAbBcC' >>> input.translate(string.maketrans(string.lowercase, '.'*26)) '...ABC.A.B.C' the string.maketrans(

pandas srt.lower() not working on dataframe column

﹥>﹥吖頭↗ 提交于 2019-12-01 21:54:44
I'm working with the Titanic dataset available from Kaggle. I have it in a dataframe and i want to change the case of the "sex" column to lowercase. I'm using the following code import pandas as pd df = pd.read_csv('titanic.csv') print dfFull['sex'].unique() df.sex.str.lower() #check if it worked print df['sex'].unique() and also trying df['sex'].str.lower() but when I run df['sex'].unique() I get three unique values [male, female, Female] . Why does my code not lower the case of the strings and save it back to the dataframe so i get [male, female] of from the .unique method? str.lower() does

Best way to convert whole file to lowercase in C

坚强是说给别人听的谎言 提交于 2019-12-01 20:46:36
I was wondering if theres a realy good (performant) solution how to Convert a whole file to lower Case in C. I use fgetc convert the char to lower case and write it in another temp-file with fputc. At the end i remove the original and rename the tempfile to the old originals name. But i think there must be a better Solution for it. If you're processing big files (big as in, say, multi-megabytes) and this operation is absolutely speed-critical, then it might make sense to go beyond what you've inquired about. One thing to consider in particular is that a character-by-character operation will

How to only lowercase quoted string in VIM

巧了我就是萌 提交于 2019-12-01 18:05:56
问题 Say I have a file with the following content: Apple 'BANANA' ORANGE 'PEACH' What is the regex to convert all quoted uppercase to lowercase? The expected output file should look like: Apple 'banana' ORANGE 'peach' 回答1: Try :%s/'\w\+'/\=tolower(submatch(0))/g '\w\+' match any word that is inside quotes. and replace it with the lowercase version of the match. \= tells substitute to evaluate the expression tolower(submatch(0)) where tolower() switches the string found in submatch(0) (the whole

Lowercase conversion in XSL

时光怂恿深爱的人放手 提交于 2019-12-01 18:02:05
I have an XML like <emps> <emp id='3432'> <fname>Jack</fname> <lname>Dawson</lname> <emp> <emp id='1122'> <fname>Jack</fname> <lname>Thompson</lname> <emp> <emps> I am developing a web application which searches this xml based on the first name entered and comes up with a resultant page. To achieve this I have written an xslt to transform the XML to HTML based on the input search string which is passed as a variable named srchStr. <xsl:template match="employees"> <xsl:for-each select="emp[fname=$srchStr]"> <tr> <xsl:variable name="id"> <xsl:value-of select="@id" /> </xsl:variable> <td> <a href

Lowercase conversion in XSL

梦想的初衷 提交于 2019-12-01 17:29:23
问题 I have an XML like <emps> <emp id='3432'> <fname>Jack</fname> <lname>Dawson</lname> <emp> <emp id='1122'> <fname>Jack</fname> <lname>Thompson</lname> <emp> <emps> I am developing a web application which searches this xml based on the first name entered and comes up with a resultant page. To achieve this I have written an xslt to transform the XML to HTML based on the input search string which is passed as a variable named srchStr. <xsl:template match="employees"> <xsl:for-each select="emp

Check if string has letter in uppercase or lowercase

送分小仙女□ 提交于 2019-12-01 16:47:29
i would like to know if it's possible check if one letter of a string is capitalized. Other way to see it, if all letters in the string are uppercase or lowercase. Example: string a = "aaaaAaa"; string b = "AAAAAa"; if(??){ //Cheking if all the string is lowercase cout << "The string a contain a uppercase letter" << endl; } if(??){ //Checking if all the string is uppercase cout << "The string b contain a lowercase letter" << endl; } you can use standard algorithm std::all_of if( std::all_of( str.begin(), str.end(), islower ) { // all lowercase } Use all_of in concert with isupper and islower :

Convert entire range to lowercase without looping through cells Indirect

天涯浪子 提交于 2019-12-01 16:07:08
I'm looking at VBA code that takes an entire range of cells and converts them into lowercase. I found the following: [A1:A20] = [index(lower(A1:A20),)] This works fine for a fixed range (don't entirely understand syntax, but found the following post:) Post detailing code above My problem is this: I would like to be able to set the range dynamically as I'm dealing with changing range sizes. However, the following doesn't work, and I can't seem to be able to use INDIRECT() either in VBA. Range("A1:A" & n) = [index(lower(Range("A1:A" & n)),)] Is there a way to make this work? I would really like

if/else statements accepting strings in both capital and lower-case letters in python

我的梦境 提交于 2019-12-01 15:57:27
问题 Is there a quick way for an "if" statement to accept a string regardless of whether it's lower-case, upper-case or both in python? I'm attempting to write a piece of code where the number "3" can be entered as well as the word "three"or "Three" or any other mixture of capital and lower-case and it will still be accepted by the "if" statement in the code. I know that I can use "or" to get it to accept "3" as well as any other string however don't know how to get it to accept the string in more