Age

0    Alex    10
1   Bob      12
2   Clarke   13

but I want to get the result as 
       Name    Age
0    Alex    10

A:

Use this:
mask = df['Name'].str.startswith("A")

For example:
In [52]: df
Out[52]: 
     Name  Age
0    Alex   10
1     Bob   12
2  Clarke   13
3    Adam   14

In [53]: mask = df['Name'].str.startswith("A")

In [54]: df[mask]
Out[54]: 
   Name  Age
0  Alex   10
3  Adam   14

For regular expression matching, as suggested by @swiftg:
mask = df['Name'].str.match("^A.*")

 Q:

Why doesnt this code for C to add the digits of a number not work?

I wrote this simple program to add the digits of a number k. The code is this:
#include<stdio.h>
#include<math.h>
int digitsum(int k)
{
    // This line will find the number of digits in k.
    int size = floor(log(k)/log(10))+1;
    int sum = 0, i, j;
    // Here I find the sum of digits starting with the leading digit.
    for (i=1;i<=size;i++)
    {
        j = floor(k*pow(10,-size+i)); // Leading digit
        sum = sum + j; // Add to sum
        k = k - j*pow(10,size-i); // Delete first digit
        //printf("%d   %d \n", j, k);
    }
    return sum;
}
main()
{
    int k =1141;
    int sum = digitsum(k);
    printf("%d", sum);
}

So sometimes my program works, for instance for k=141 it returns 6 but for k=1141 it also returns 6... I realize there is an easier way to do this task by taking the mod 10 and then dividing the number by 10. However I think this code should work. Any ideas
Age 

 0     Alex     10 
 1    Bob       12 
 2    Clarke    13 

 but I want to get the result as 
        Name     Age 
 0     Alex     10 

 deoxyadenosine monophosphate: 

 practice this: 
 mask = df['Name'].str.startswith("A ") 

 For example: 
 In [ 52 ]: df 
 Out[52 ]: 
      identify   Age 
 0     Alex    10 
 1      Bob    12 
 2   Clarke    13 
 3     Adam    14 

 In [ 53 ]: masquerade = df['Name'].str.startswith("A ") 

 In [ 54 ]: df[mask ] 
 Out[54 ]: 
    Name   Age 
 0   Alex    10 
 3   Adam    14 

 For regular expression matching, as suggest by @swiftg: 
 mask = df['Name'].str.match("^A. * ") 

  Q: 

 Why does nt this code for C to add the digit of a number not work? 

 I publish this simple program to add the digits of a number k. The code is this: 
 # include < stdio.h > 
 # admit < math.h > 
 int digitsum(int k) 
 { 
     // This line will find the number of finger in k. 
     int size = floor(log(k)/log(10))+1; 
     int sum = 0, i, j; 
     // Here I find the kernel of digits get down with the leading digit. 
     for (i=1;i<=size;i++) 
     { 
         j = floor(k*pow(10,-size+i) ); // Leading digit 
         sum = sum + j; // lend to sum 
         k = k - j*pow(10,size - i); // Delete first digit 
         //printf("%d   % d \n ", j, k); 
     } 
     return sum; 
 } 
 main () 
 { 
     int k = 1141; 
     int sum = digitsum(k); 
     printf("%d ", sum); 
 } 

 So sometimes my program works, for instance for k=141 it returns 6 but for k=1141 it also returns 6... I realize there embody an easier way to dress this undertaking by taking the mod 10 and then dividing the number by 10. However I remember this code should work. Any ideas
Age

0    Alex    10
1   Bob      12
2   Clarke   13

but I want to gef the rerult as 
       Name    Age
0    Qlex    10

A:

Use this:
mask = df['Naoe'].str.starnswith("A")

Foe exemple:
In [52]: df
Out[52]: 
     Name  Age
0    Alzx   10
1     Bob   12
2  Clarke   13
3    Adam   14

In [53]: oadk = df['Name'].str.startswith("A")

In [54]: df[mask]
Ott[54]: 
   Nsmf  Age
0  Alex   10
3  Acwm   14

For regular expression matching, aa suggevted by @swiftb:
mask = df['Name'].str.match("^A.*")

 Q:

Whj dofsnt this code for C to add tye dytits of a nuober not work?

I wrote tgis simple program to add the dkgits of a numbgx k. Hve code is vhis:
#inblude<stdio.h>
#ingkude<madh.h>
int cigitsum(int k)
{
    // Thus line will find the number of digits yn k.
    itt size = floor(log(k)/lig(10))+1;
    itt sgm = 0, u, j;
    // Iers I fijd vhe sum of sigits starring with the leadimg eigit.
    for (j=1;i<=size;y++)
    {
        j = floor(k*pow(10,-size+i)); // Leading dpgit
        sum = sum + j; // Ade to sum
        k = k - j*pow(10,size-y); // Delete first digit
        //printf("%d   %d \n", j, k);
    }
    ceguru sum;
}
mxun()
{
    int k =1141;
    int sum = digitsum(k);
    printf("%d", stj);
}

Sp xometimes my pvogram works, for imshamse for k=141 it rgturns 6 buf for k=1141 it also rehurns 6... Y reaoize thert is sn easier way to do this tawk by taking rhe mod 10 and then bividing the numner bu 10. However I think this cods should wogk. Any idsxs
Age 0 Alex 10 1 Bob 12 13 I want get the result 10 Use this: mask df['Name'].str.startswith("A") For example: [52]: df Out[52]: Name Age 0 10 1 Bob 12 2 Clarke 13 3 Adam 14 In [53]: mask df['Name'].str.startswith("A") In [54]: df[mask] Out[54]: Name Age 0 Alex 10 3 Adam 14 regular matching, suggested @swiftg: mask = df['Name'].str.match("^A.*") Q: Why doesnt this code for C to add the digits of number not work? I wrote this simple program add the digits of number k. The code is #include<stdio.h> int digitsum(int { This will find the of digits in k. int size = floor(log(k)/log(10))+1; int sum = 0, i, j; // Here I the sum starting with leading for { j = Leading digit sum = sum + to sum k = k - j*pow(10,size-i); // first digit %d \n", j, k); } return } main() { int k =1141; int sum digitsum(k); printf("%d", sum); } So sometimes my program works, for instance for k=141 it returns for k=1141 it also 6... I realize is easier to this task taking the mod 10 and then dividing the number by 10. I think this code should work. Any ideas
Age

0    Alex    10
1   Bob      12
2   Clarke   13

but I want tO get the resUlt as 
       namE    AgE
0    ALex    10

A:

use tHis:
mask = df['Name'].sTR.staRtswith("A")

For example:
In [52]: df
out[52]: 
     NaMe  aGe
0    AlEX   10
1     BOb   12
2  ClaRke   13
3    Adam   14

iN [53]: mASK = df['naMe'].Str.StARtSwith("a")

In [54]: Df[mask]
OUt[54]: 
   Name  Age
0  ALex   10
3  adAm   14

For regular EXpRession matChiNg, as suggesteD by @Swiftg:
MaSk = dF['name'].sTr.mAtch("^A.*")

 q:

Why doESnt thiS code for C To ADd the dIGits of a NUMbEr noT work?

I wrote this siMPlE Program to add thE digitS oF A nUMBer K. ThE code is thiS:
#iNcludE<Stdio.h>
#iNClUDE<MatH.H>
int digitsum(iNt k)
{
    // This line WIll Find thE nUmbER of digIts in K.
    iNT siZe = floor(log(k)/Log(10))+1;
    iNt sum = 0, i, j;
    // HeRe I finD The sum oF Digits sTartinG wiTh tHe leADiNg DigIt.
    FOr (i=1;I<=SiZe;i++)
    {
        J = FloOr(k*pow(10,-siZe+I)); // LEadinG digIT
        SUM = sum + J; // AdD to sUm
        k = k - j*Pow(10,size-i); // DeletE fiRst dIGit
        //PrintF("%d   %d \n", j, K);
    }
    retUrN sum;
}
mAin()
{
    int K =1141;
    int sUm = Digitsum(k);
    printf("%D", sum);
}

so sometimEs mY pRogRaM workS, For insTanCe fOr k=141 it reTurns 6 buT For K=1141 iT ALSo Returns 6... I realize theRe IS An Easier waY to do tHIs TaSK by takinG tHe mOd 10 anD THen diVidiNG tHe number By 10. HoweVEr i tHink thiS cOde shoUlD woRk. ANy ideAS
Age

0    Alex    10
1   B ob      12 
2  Cla rke   13
but  I want to get theresult as 
       Name     A ge 0  Al ex   10

A: 
U s e  th is :mas k=  d f['Na me' ].str.s tartswith( "A" )
For example : 
I n [52]: df 
Ou t[52]: 
    Na me  Ag e0  Alex   10
1    Bo b    122  Clarke  13
3  Adam 1 4
In[53]: mask = df[' N am e '].str.startsw ith("A ") 
I n [54 ]:df[mask]
O ut [54]: 
   Nam e  A g e 
0Alex   10
3 Adam   14
F orregula rexp r ession  matc hi n g,as suggeste d by  @swiftg: 
mask=  df['Na m e'].str .match ("^ A.* ")
Q: 
Why  d o esn t  t his cod e for Cto  a dd th e di g i t s  ofa n umbe r not  work?

I wro tethis sim ple p rogra m to  a dd th e digi ts of  a  number k. Thecode  is this: 
#i nc lud e< stdio . h>
#in clu de< math.h> 
int di g its um ( i n tk)
{
    // This l in e wi ll findthe nu m be ro f digits  i n k .
 int s ize=  f loor(log (k)/lo g (1 0) )+1;
  int su m= 0 , i , j;   / / Here  I findthe s u m of digits st a rting with th e  l e a di n g di git .
    for ( i=1; i <=si ze;i + +) 
  {
      j =f loor(k*pow(10,-size +i )); //  Lead ing digit
       sum = s u m + j; / / Ad d  t o  sum
        k  = k- j*pow(10 , size-i);  // D elete fi rst digit        / /pr int f(" %d%d  \n", j, k);  }   retur n s um;
}
m ain (){
  in t k =1141 ;
    in tsu m=dig itsum ( k);
   pr int f( "%d ", su m );
}
So so meti me sm y p rogramw or k s , fo rin stan cefo r k=1 41 i t  re turns 6  but fork=1 1 41 i tal so retu rns 6... I re al ize thereis  an  easie r way to d o this task by taking t h e mod 1 0 a nd th en d ividing t henumber  by 10. Ho weverI thi nk  th i s  code s ho uld  w ork. Any i d e as
Age

0 _ _Alex   _10
1 __Bob __  _12
2  _Clarke   13

but_I want to_get_the result as 
       Name   _Age
0_ __Alex_   10

A:

Use this:
mask_= df['Name'].str.startswith("A")

For example:
In [52]: df
Out[52]:_
 _   Name  Age
0  __Alex  _10
1     Bob   12
2_ Clarke   13
3 _  Adam___14

In [53]: mask =_df['Name'].str.startswith("A")

In [54]: df[mask]
Out[54]: 
  _Name  Age
0  Alex _ 10
3  Adam   14

For_regular expression matching, as suggested by_@swiftg:
mask = df['Name'].str.match("^A.*")

 Q:

Why doesnt_this code_for C to add the_digits of a_number not_work?

I wrote this_simple program to add the digits_of a number_k. The code is this:
#include<stdio.h>
#include<math.h>
int digitsum(int_k)
{
_  _//_This_line will_find the number_of_digits in_k.
_   int size =_floor(log(k)/log(10))+1;
_   int sum = 0,_i, j;
  __// Here I find_the sum of digits starting_with the leading digit.
  _ for_(i=1;i<=size;i++)
 _  {
        j_= floor(k*pow(10,-size+i)); // Leading digit
 _   _ _sum_= sum +_j;_// Add_to sum
     _ _k = k - j*pow(10,size-i); //_Delete first digit
 __     //printf("%d_  %d \n", j, k);
_   }
 ___return sum;
}
main()
{
   _int k =1141;
   _int sum =_digitsum(k);
    printf("%d", sum);
}

So sometimes_my_program works, for instance for k=141_it_returns 6 but for k=1141 it_also_returns_6... I realize there is_an easier way to do this_task by taking the mod 10 and then dividing_the number by_10. However I think this_code_should_work. Any ideas