Eric T
Eric T

Reputation: 11

Pandas Dataframe but does not display filtered results. Filter Logic works, display shows NaT for filtered results

I am trying to simply filter based on the date in the Date_Start column and return a dataframe that includes the index, Full_Path and Date_Start columns. Seems like all examples I have found do not return the NaN and NaT I am receiving as seen below. On Pandas .22 and Python 2.7.13.

In: FilesFrame
Out:
     Full_Path                                 Date_Start
0    \\file_path\file2018-02-12_20-47-01.txt   2018-02-12 20:47:01 
1    \\file_path\file2018-02-12_20-47-01.txt   2018-02-12 20:47:01
2    \\file_path\file2018-02-12_20-47-01.txt   2018-02-12 20:47:01
3    \\file_path\file2018-02-15_20-47-05.txt   2018-02-15 20:47:05

In[2]:  start_date = '2018-02-15 20:47:05'
In[3]:  condition1 = FilesFrame['Date_Start'] == start_date
In[4]:  FilesFrame[(condition1)]
Out[4]:
     Full_Path                                 Date_Start
0    NaN                                       NaT 
1    NaN                                       NaT
2    NaN                                       NaT
3    NaN                                       2018-02-15 20:47:05

Desired result:

     Full_Path  
3    \\file_path\file2018-02-15_20-47-05.txt   2018-02-15 20:47:05

Additional Information:

In[5]: FilesFrame.dtypes
Out[5]:
Full_Path     object
Date_Start    datetime64[ns]

Upvotes: 1

Views: 67

Answers (1)

Eric T
Eric T

Reputation: 11

Thanks to ayhan for testing and taking a guess. It turned out that when I assigned the 'Full_Path' column I added it like this:

FilesFrame.columns = [['Full_Path']]

Instead of:

FilesFrame.columns = ['Full_Path']

This was similar to his suggestion and resolves this issue.

Upvotes: 0

Related Questions