Python Forum
pandas restricting csv read to certain rows
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas restricting csv read to certain rows
#2
You should look here:
https://stackoverflow.com/questions/1746...nize-dates
https://stackoverflow.com/questions/2937...-two-dates

import pandas as pd


df = pd.read_csv('dates.csv', delimiter=';', parse_dates=['date'])
print(df.dtypes)
mask =(df['date'] > pd.Timestamp(2012,1,1)) & (df['date'] < pd.Timestamp(2016,1,1))
print(df[mask])
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: pandas restricting csv read to certain rows - by DeaD_EyE - Dec-06-2017, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,751 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
Smile How to further boost the data read write speed using pandas tjk9501 1 1,287 Nov-14-2022, 01:46 PM
Last Post: jefsummers
  Pandas Dataframe Filtering based on rows mvdlm 0 1,470 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  [Pandas] Help with finding only non-matching rows LowEnd 3 3,631 Nov-12-2021, 02:34 PM
Last Post: jefsummers
  Can't read text file with pandas zinho 6 12,194 May-24-2020, 06:13 AM
Last Post: azajali43
  Read json array data by pandas vipinct 0 1,972 Apr-13-2020, 02:24 PM
Last Post: vipinct
  pandas head() not reading all rows naab 0 1,829 Apr-07-2020, 01:06 PM
Last Post: naab
  getting trailing zeros with 1 during pandas read fullstop 1 3,650 Jan-05-2020, 04:01 PM
Last Post: ichabod801
  How to add a few empty rows into a pandas dataframe python_newbie09 2 16,386 Sep-20-2019, 08:52 AM
Last Post: python_newbie09
  Read Nested JSON with pandas.io.json palo173 4 9,639 Apr-29-2019, 01:25 PM
Last Post: palo173

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020