I have a csv file that contains 90000 lines with a date format index. I don't need to read the first 9 lines because that's info that doesn't concern me. I've tried like this:
df_dados = pd.read_csv('dados.csv', skiplines=9, index_col=0, parse_dates=['timestamp'])
Unfortunally it doesn't work, and the only way I've surpassed this is by modifying the file which I wouldn't like to do. Is there a way to skip lines and set the time index?
The skiprows
argument of pandas.read_csv()
can be either list-like, an integer, or a callable.
True
or False
depending on whether the row should be skipped or not. Since you want to skip the first 9 lines, try passing skiprows=range(9)
.
df_dados = pd.read_csv('dados.csv', skiprows=range(9), index_col=0, parse_dates=['timestamp'])
Note: The line numbers to skip are 0-indexed (first line is index 0
, second is index 1
, etc.).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.