w3resource

Pandas Time Series: Exercises, Practice, Solution

[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]

Pandas Time Series [ 32 exercises with solution]

1. Write a Pandas program to create
a) Datetime object for Jan 15 2012.
b) Specific date and time of 9:20 pm.
c) Local date and time.
d) A date without time.
e) Current date.
f) Time from a datetime.
g) Current local time.
Click me to see the sample solution

2. Write a Pandas program to create
a) a specific date using timestamp.
b) date and time using timestamp.
c) a time adds in the current local date using timestamp.
d) current date and time using timestamp.
Click me to see the sample solution

3. Write a Pandas program to create a date from a given year, month, day and another date from a given string formats.
Click me to see the sample solution

4. Write a Pandas program to print the day after and before a specified date. Also print the days between two given dates.
Click me to see the sample solution

5. Write a Pandas program to create a time-series with two index labels and random values. Also print the type of the index.
Click me to see the sample solution

6. Write a Pandas program to create a time-series from a given list of dates as strings.
Click me to see the sample solution

7. 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.
Click me to see the sample solution

8. Write a Pandas program to create a date range using a startpoint date and a number of periods.
Click me to see the sample solution

9. Write a Pandas program to create a whole month of dates in daily frequencies. Also find the maximum, minimum timestamp and indexs.
Click me to see the sample solution

10. Write a Pandas program to create a time series using three months frequency.
Click me to see the sample solution

11. Write a Pandas program to create a sequence of durations increasing by an hour.
Click me to see the sample solution

12. Write a Pandas program to convert year and day of year into a single datetime column of a dataframe.
Click me to see the sample solution

13. Write a Pandas program to create a series of Timestamps from a DataFrame of integer or string columns. Also create a series of Timestamps using specified columns.
Click me to see the sample solution

14. Write a Pandas program to check if a day is a business day (weekday) or not.
Click me to see the sample solution

15. Write a Pandas program to get a time series with the last working days of each month of a specific year.
Click me to see the sample solution

16. Write a Pandas program to create a time series combining hour and minute.
Click me to see the sample solution

17. Write a Pandas program to convert unix/epoch time to a regular time stamp in UTC. Also convert the said timestamp in to a given time zone.
Click me to see the sample solution

18. Write a Pandas program to create a time series object with a time zone.
Click me to see the sample solution

19. Write a Pandas program to remove the time zone information from a Time series data.
Click me to see the sample solution

20. Write a Pandas program to subtract two timestamps of same time zone or different time zone.
Click me to see the sample solution

21. Write a Pandas program to calculate all Thursdays between two given days.
Click me to see the sample solution

22. Write a Pandas program to find the all the business quarterly begin and end dates of a specified year.
Click me to see the sample solution

23. Write a Pandas program to generate sequences of fixed-frequency dates and time spans intervals.
Click me to see the sample solution

24. Write a Pandas program to generate time series combining day and intraday offsets intervals.
Click me to see the sample solution

25. Write a Pandas program to extract the day name from a specified date. Add 2 days and 1 business day with the specified date.
Click me to see the sample solution

26. Write a Pandas program to convert integer or float epoch times to Timestamp and DatetimeIndex.
Click me to see the sample solution

27. Write a Pandas program to calculate one, two, three business day(s) from a specified date. Also find the next business month end from a specific date.
Click me to see the sample solution

28. Write a Pandas program to create a period index represent all monthly boundaries of a given year. Also print start and end time for each period object in the said index.
Click me to see the sample solution

29. Write a Pandas program create a series with a PeriodIndex which represents all the calendar month periods in 2029 and 2031. Also print the values for all periods in 2030.
Note: PeriodIndex is an immutable ndarray holding ordinal values indicating regular periods in time such as particular years, quarters, months, etc.
Click me to see the sample solution

30. Write a Pandas program to generate holidays between two dates using the US federal holiday calendar.
Click me to see the sample solution

31. Write a Pandas program to create a monthly time period and display the list of names in the current local scope.
Click me to see the sample solution

32. Write a Pandas program to create a yearly time period from a specified year and display the properties of this period.
Click me to see the sample solution

Python Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.

Test your Python skills with w3resource's quiz



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/python-exercises/pandas/time-series/index.php