Johan Nilssons Lifestream

How can I delete partial contents of a cell in a column using pandas (Python)

So I am attempting to edit an entire column cell by cell to change the column from something that contains integer and string to just the integer component. For example

one cell looks like:

3001234; textTEXT TextTeXTExt.TExt

I am using this command:

df2.columns[3] = df2.columns[3].map(lambda x: x.lstrip([5:]))

Ive also tried something like this:

df2.columns[3] = df2.columns[3].split([])

This is the error I get from ipython:

AttributeError: 'unicode' object has no attribute 'map'

Actual column from data frame:

0                           11212; xxxxxxxxxx xxxxxxxx   
1                           11212; xxxxxxxxxx xxxxxxxx   
2                           11212; xxxxxxxxxx xxxxxxxx   
3                           11212; xxxxxxxxxx xxxxxxxx     
8                  667788; xxxxxxx xxxxxxxxxxxxx xxxxxx   
9                  55555; xxxxxxx xxxxxxxxxxxxx xxxxxx   
10                 55555; xxxxxxx xxxxxxxxxxxxx xxxxxx   
11                 55555; xxxxxxx xxxxxxxxxxxxx xxxxxx   
12                 33333; xxxxxxx xxxxxxxxxxxxx xxxxxx   
13                 333; xxx xxxxx @ xxx xxx 2 xxxx   
14                 9991; xxxx; xxxxxx xxxxx xxxx @ 2 xxx   
18                       1635; vvvvvvvvvvvv vvvvvv 10   
19                       1635; vvvvvvvvvvvv vvvvvv 10   
20                       1635; vvvvvvvvvvvv vvvvvv 10   
21                       1635; vvvvvvvvvvvv vvvvvv 10     
32                       1712; Cxxxx xxxxxxxx; xxx 0   
33                       1712; Cxxxx xxxxxxxx; xxx 0   
34                       1712; Cxxxx xxxxxxxx; xxx 0   
35                       1712; Cxxxx xxxxxxxx; xxx 0

via Stack Overflow

blog comments powered by Disqus
Get the source for phplifestream at Github