Assuming you have a column that consists of integers, floats, and strings, which are all read in as strings from a file, you'll have something like this:
s = pd.Series(['10', '20', '30.4', '40.7', 'text', 'more text', '50.0'])
in which case, you can apply a function to convert the floats to integers, then a second function to convert the integers (back) to strings:
import pandas as pd
def print_type(x):
print(type(x))
return x
def to_int(x):
try:
# x is a float or an integer, and will be returned as an integer
return int(pd.to_numeric(x))
except ValueError:
# x is a string
return x
def to_str(x):
return str(x)
s = pd.Series(['10', '20', '30.4', '40.7', 'text', 'more text', '50.0'])
s2 = s.apply(to_int).apply(to_str)
print("Series s:")
print(s)
print("\nSeries s2:")
print(s2)
print("\nData types of series s2:")
print(s2.apply(print_type))
Here is the output, showing that, in the end, each number has been converted to a string version of an integer:
Series s:
0 10
1 20
2 30.4
3 40.7
4 text
5 more text
6 50.0
dtype: object
Series s2:
0 10
1 20
2 30
3 40
4 text
5 more text
6 50
dtype: object
Data types of series s2:
<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
<class 'str'>
0 10
1 20
2 30
3 40
4 text
5 more text
6 50
dtype: object
Not sure if that's what you're after, but if not, hopefully it will give you an idea of how to get started. This is using Pandas 0.19.2:
In [1]: import pandas as pd
In [2]: print(pd.__version__)
0.19.2