@@ -971,6 +971,57 @@ Parsing date components in multi-columns is faster with a format
971971 In [36 ]: % timeit pd.to_datetime(ds)
972972 1 loops, best of 3 : 488 ms per loop
973973
974+ Skip row between header and data
975+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
976+
977+ .. ipython :: python
978+
979+ from io import StringIO
980+ import pandas as pd
981+
982+ data = """ ;;;;
983+ ;;;;
984+ ;;;;
985+ ;;;;
986+ ;;;;
987+ ;;;;
988+ ;;;;
989+ ;;;;
990+ ;;;;
991+ ;;;;
992+ date;Param1;Param2;Param4;Param5
993+ ;m²;°C;m²;m
994+ ;;;;
995+ 01.01.1990 00:00;1;1;2;3
996+ 01.01.1990 01:00;5;3;4;5
997+ 01.01.1990 02:00;9;5;6;7
998+ 01.01.1990 03:00;13;7;8;9
999+ 01.01.1990 04:00;17;9;10;11
1000+ 01.01.1990 05:00;21;11;12;13
1001+ """
1002+
1003+ Option 1: pass rows explicitly to skiprows
1004+ """"""""""""""""""""""""""""""""""""""""""
1005+
1006+ .. ipython :: python
1007+
1008+ pd.read_csv(StringIO(data.decode(' UTF-8' )), sep = ' ;' , skiprows = [11 ,12 ],
1009+ index_col = 0 , parse_dates = True , header = 10 )
1010+
1011+ Option 2: read column names and then data
1012+ """""""""""""""""""""""""""""""""""""""""
1013+
1014+ .. ipython :: python
1015+
1016+ pd.read_csv(StringIO(data.decode(' UTF-8' )), sep = ' ;' ,
1017+ header = 10 , parse_dates = True , nrows = 10 ).columns
1018+ columns = pd.read_csv(StringIO(data.decode(' UTF-8' )), sep = ' ;' ,
1019+ header = 10 , parse_dates = True , nrows = 10 ).columns
1020+ pd.read_csv(StringIO(data.decode(' UTF-8' )), sep = ' ;' ,
1021+ header = 12 , parse_dates = True , names = columns)
1022+
1023+
1024+
9741025 .. _cookbook.sql :
9751026
9761027SQL
0 commit comments