Answers for "list of string values to int python pandas dataframe"

0

how to convert each string to a category or int in python dataframe

In [3]: df = pd.DataFrame({"A": ["a", "b", "c", "a"]})

In [4]: df["B"] = df["A"].astype('category')

In [5]: df
Out[5]: 
   A  B
0  a  a
1  b  b
2  c  c
3  a  a
Posted by: Guest on November-20-2020
0

pandas convert string column to int list column

df_out['gids'] = df_out['gids'].map(lambda x: list(map(int, filter(None, x.split(' ')))))
Posted by: Guest on September-01-2021

Code answers related to "list of string values to int python pandas dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language