Pandas: Create a time-series from a given list of dates as strings
Pandas Time Series: Exercise-6 with Solution
Write a Pandas program to create a time-series from a given list of dates as strings.
Python Code :
import pandas as pd import numpy as np import datetime from datetime import datetime, date dates = ['2014-08-01','2014-08-02','2014-08-03','2014-08-04'] time_series = pd.Series(np.random.randn(4), dates) print(time_series)
2014-08-01 2.025858 2014-08-02 0.307073 2014-08-03 -0.903682 2014-08-04 0.056662 dtype: float64
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Pandas program to create a time-series with two index labels and random values. Also print the type of the index.
Next: Write a Pandas program to create a time series object that has time indexed data. Also select the dates of same year and select the dates between certain dates.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
>>> "Python ROCK" if True else " I AM GRUMPY" "Python ROCK"
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework