I have the "Weight " column in my data frame but in CSV file, there are many of unwanted text, and I need to remove the letters and all characters except (.) the dot from column example:
import pandas as pd
df = pd.DataFrame(
[
(1, '+9.1A', 100),
(2, '-1A', 121),
(3, '5B', 312),
(4, '+1D', 567),
(5, '+1C', 123),
(6, '-2E', 101),
(7, '+3T', 231),
(8, '5A', 769),
(9, '+5B', 907),
(10, 'text', 15),
],
columns=['colA', 'weight', 'colC']
)
print(df)
the expected result is :
Real Example
df = pd.DataFrame(
[
(0,68),
(1,67),
(2,68.1),
(3,97.1),
(4,113.9),
(5,114),
(6,112),
(7,111.8),
(8,111),
(9,110.8),
(10,111.2),
(11,),
(12,111.5),
(13,'Not Appropriate at t'),
],
columns=['colA', 'weight']
)
print(df)