Jul-29-2017, 10:11 AM
I am not familiar with pandas (pandas is cool), but if you're iterating over the input line by line, you can parse it. I do it with the python stdlib:
For pandas there are many helper functions to make it easier as my example with datetime.
I guess pandas do also have a filter function for this task, that you don't need to iterate like me over the data set by yourself.
import datetime from io import StringIO text = """0 2016-01-01 0000000 1458641 2016-04-22 06:57:41 1458642 2016-01-05 15:56:26""" like_file = StringIO(text) # acts as a file, supports also iteration which gives you line by line in a loop # using your holidays object for line in like_file: _, date, time = line.split() date = datetime.datetime.strptime(date, '%Y-%M-%d').date() # this converts the str to a date object if date in holidays: # here is the magic, the in operator works also with pandas data frames # this should also work with a field a column from a pandas data frame print(line)You just need a method to convert your input data to a pandas data frame and do the right job to parse the columns for each row.
For pandas there are many helper functions to make it easier as my example with datetime.
I guess pandas do also have a filter function for this task, that you don't need to iterate like me over the data set by yourself.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!