Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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 :: python pop 
Python :: python list all but first 
Python :: python openpyxl cell width 
Python :: new column with multiple conditions 
Python :: reverse python 
Python :: pandas drop duplicate keep last 
Python :: Iniciar servidor en Django 
Python :: python copy a dictionary to a new variable 
Python :: Sum items in a list with ints and strings in python 
Python :: rotate matrix python 
Python :: python unittest 
Python :: opencv convert black pixels to white 
Python :: how to call a random function in python 
Python :: check if the user is logged in django decorator 
Python :: represent NaN with pandas in python 
Python :: Range python iterate by 2 
Python :: python example 
Python :: how to terminate subprocess.call in python 
Python :: How To Get Redirection URL In Python 
Python :: get definition of word python 
Python :: python save to excel 
Python :: driver code in python 
Python :: how to run python file from cmd 
Python :: python logging 
Python :: python script to scrape data from website 
Python :: how to put python code on a website 
Python :: python to run excel macro 
Python :: remove multiple strings from list python 
Python :: make a condition statement on column pandas 
Python :: tqdm in place 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =