Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas read csv specify column dtype

import pandas as pd
import numpy as np

data = '''
1,2,3
4,5,6'''

fileobj = pd.compat.StringIO(data)
df = pd.read_csv(fileobj, dtype={0:'int8',1:'int8',2:'int32'}, header=None)

print(df.dtypes)
Comment

PREVIOUS NEXT
Code Example
Python :: how to find missing item in a list 
Python :: tkinter hide widget 
Python :: ord python3 
Python :: Solve linear equation with np.linalg.solve 
Python :: how to import matplotlib in python 
Python :: pip config proxy 
Python :: python for loop 
Python :: Python How to convert a string to the name of a function? 
Python :: tkinker 
Python :: run julia in p;ython 
Python :: sklean tfidf 
Python :: Install Pip 2 on ubuntu linux 
Python :: python minecraft server python gui 
Python :: calculate area under the curve in python 
Python :: python remove header 
Python :: list of dictionary values 
Python :: how to make colab reload on form change 
Python :: change gles3 to gles2 
Python :: python var power of 2 
Python :: define a string in python 
Python :: python cant find keras utils to_categorical 
Python :: Resource stopwords not found 
Python :: fetch last record from django model 
Python :: unpersist cache pyspark 
Python :: Python update to beginning of dictionary 
Python :: Adding Route In Django 
Python :: how to get the output in rupees in pandas 
Python :: cv2 remove black borders on images 
Python :: classes in python 
Python :: change state enabled tkinter 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =