https://gist.github.com/gauravmeena0708/78770ccffb0e008cf25b0261e47fb7d8
https://gist.github.com/gauravmeena0708/71a64e34a8e1a0e49927a288cfb3d7a8
https://gist.github.com/gauravmeena0708/4f3e6c1009dec4446ff93ac011be26cf
data = 'a,b,c\n1,2,3\n4,5,6\n7,8,9'
pd.read_csv(StringIO(data), names=['foo', 'bar', 'baz'], header=0)
data = 'skip this skip it\na,b,c\n1,2,3\n4,5,6\n7,8,9'
pd.read_csv(StringIO(data), header=1)
pd.read_csv(StringIO(data), usecols=['b', 'c'])
pd.read_csv(StringIO(data), usecols=[0, 2, 3])
pd.read_csv(StringIO(data), usecols=lambda x: x not in ['a', 'c'])
data = '\na,b,c\n \n# commented line\n1,2,3\n\n4,5,6'
pd.read_csv(StringIO(data), comment='#')
data = 'a,b,c\n\n1,2,3\n\n\n4,5,6'
pd.read_csv(StringIO(data), skip_blank_lines=False)
data = '# empty\n# second empty line\n# third empty' \
'line\nX,Y,Z\n1,2,3\nA,B,C\n1,2.,4.\n5.,NaN,10.0'
pd.read_csv(StringIO(data), comment='#', skiprows=4, header=1)
Comments
Post a Comment