Answers for "remove string from column pandas"

3

pandas remove char from column

df['result'] = df['result'].str.replace(r'\D', '')
df

    time result
1  09:00     52
2  10:00     62
3  11:00     44
4  12:00     30
5  13:00    110
Posted by: Guest on November-13-2020
0

remove columns that contain string pandas

df = df[df.columns.drop(list(df.filter(regex='Test')))]
Posted by: Guest on August-12-2021
0

drop portion of string in dataframe python

data['result'] = data['result'].map(lambda x: x.lstrip('+-').rstrip('aAbBcC'))
Posted by: Guest on November-08-2021
0

remove columns that contain string pandas

import pandas as pd

import numpy as np

array=np.random.random((2,4))

df=pd.DataFrame(array, columns=('Test1', 'toto', 'test2', 'riri'))

print df

      Test1      toto     test2      riri
0  0.923249  0.572528  0.845464  0.144891
1  0.020438  0.332540  0.144455  0.741412

cols = [c for c in df.columns if c.lower()[:4] != 'test']

df=df[cols]

print df
       toto      riri
0  0.572528  0.144891
1  0.332540  0.741412
Posted by: Guest on August-12-2021

Code answers related to "remove string from column pandas"

Python Answers by Framework

Browse Popular Code Answers by Language