Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas read csv dtype list

from ast import literal_eval
df = pd.read_csv("in.csv",converters={"Col3": literal_eval})

# Or, if you are sure the format is the same for all strings, stripping and splitting will be a lot faster:
df = pd.read_csv("in.csv",converters={"Col3": lambda x: x.strip("[]").split(", ")})
# But you will end up with the strings wrapped in quotes
Comment

PREVIOUS NEXT
Code Example
Python :: torch root mean square 
Python :: how to check if character in string python 
Python :: os.startfile 
Python :: sort a dict by values 
Python :: tkinter filedialog how to show more than one filetype 
Python :: flat numpy array 
Python :: how to scale an array between two values python 
Python :: python generic 
Python :: array creation method in numpy 
Python :: R sample() funciton in python 
Python :: get number in string python 
Python :: properties of tuples in python 
Python :: django template render dict 
Python :: plotly coordinates mapping 
Python :: how to add list numbers in python 
Python :: username python 
Python :: class indexing 
Python :: django abstractuser 
Python :: return mean of df as dataframe 
Python :: adfuller test in python 
Python :: percent in pandas 
Python :: freecodecamp python 
Python :: tables in python 
Python :: comtypes python 
Python :: The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now 
Python :: how to print during multiprocessing 
Python :: how to write a python comment 
Python :: how to find length of list python 
Python :: pandas dataframe row names 
Python :: simple seaborn heatmap 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =