Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas change column to a string

total_rows['ColumnID'] = total_rows['ColumnID'].astype(str)
Comment

in dataframe particular column to string


df["fruit"] = df["fruit"].astype("|S")
Comment

convert certain columns to string pandas

# column names which need to be string
lst_str_cols = ['prefix', 'serial']
dict_dtypes = {x: 'str' for x in lst_str_cols}
pd.read_csv('sample.csv', dtype=dict_dtypes)
Comment

PREVIOUS NEXT
Code Example
Python :: find time of run for python code 
Python :: python move file 
Python :: python copy paste file 
Python :: install imageio 
Python :: python if main 
Python :: WARNING: There was an error checking the latest version of pip. 
Python :: round python with list 
Python :: check filed exist in object python 
Python :: copy to clipboard python 
Python :: matplotlib figsize 
Python :: select first word in string python 
Python :: install streamlit 
Python :: pyspark convert float results to integer replace 
Python :: download from url using urllib python 
Python :: get text from txt file python 
Python :: remove ticks matplotlib 
Python :: simple imputer python 
Python :: extended euclidean python 
Python :: format to 2 or n decimal places python 
Python :: python reload file if changed 
Python :: export data csv 
Python :: update python ubuntu 
Python :: pandas update with condition 
Python :: python sort a list of tuples 
Python :: save df to txt 
Python :: get current date and time with python 
Python :: pandas shuffle rows 
Python :: folium anaconda 
Python :: pandas add dataframe to the bottom of another 
Python :: random date python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =