How to use pandas series with date range in Python

2 Answers

0 votes
import pandas as pd 

psr = pd.Series(['python', 'java', 'c++', 'c', None, 'php' ]) 
  
idx = pd.date_range('2020-5-15', periods = 6) 
  
psr.index = idx 

print(psr) 
  
  
  
'''
run:
  
2020-05-15    python
2020-05-16      java
2020-05-17       c++
2020-05-18         c
2020-05-19      None
2020-05-20       php
Freq: D, dtype: object
                
'''

 



answered May 15, 2020 by avibootz
0 votes
import pandas as pd 

psr = pd.Series(['python', 'java', 'c++', 'c', None, 'php' ]) 
  
idx = pd.date_range('2020-5-15', periods = 6) 
  
psr.index = idx 

print(psr.get(key = '2020-05-17') ) 
  
  
  
'''
run:
  
c++
                
'''

 



answered May 15, 2020 by avibootz

Related questions

2 answers 201 views
201 views asked May 15, 2020 by avibootz
1 answer 132 views
132 views asked Jun 27, 2020 by avibootz
1 answer 156 views
1 answer 188 views
1 answer 166 views
1 answer 153 views
153 views asked Jan 1, 2021 by avibootz
...