Posts

Showing posts from August, 2017

Pandas snips

https://gist.github.com/gauravmeena0708/78770ccffb0e008cf25b0261e47fb7d8   https://gist.github.com/gauravmeena0708/71a64e34a8e1a0e49927a288cfb3d7a8   https://gist.github.com/gauravmeena0708/4f3e6c1009dec4446ff93ac011be26cf   data = 'a,b,c \n 1,2,3 \n 4,5,6 \n 7,8,9' pd . read_csv ( StringIO ( data ), names = [ 'foo' , 'bar' , 'baz' ], header = 0 )   data = 'skip this skip it \n a,b,c \n 1,2,3 \n 4,5,6 \n 7,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 = ' \n a,b,c \n \n # commented line \n 1,2,3 \n\n 4,5,6' pd . read_csv ( StringIO ( data ), comment = '#' )       data = 'a,b,c \n\n 1,2,3 \n\n\n 4,5,6' pd . read_csv ( StringIO