Tag Archives: python for beginners

How to Visualize Machine Learning Data in Python using Pandas

(How to Visualize Machine Learning Data in Python using Pandas) In this Learn through Codes example, you will learn How to Visualize Machine Learning Data in Python using Pandas.  Visualize_Machine_Learning_Data_in_Python_using_Pandas Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects for Aspiring Data Scientists: Tabular Text & …

How to tune Parameters in Python using scikit learn

(How to tune Parameters in Python using scikit learn) In this Learn through Codes example, you will learn How to tune Parameters in Python using scikit learn.  How_to_tune_Parameters_in_Python_using_scikit_learn   Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects for Aspiring Data Scientists: Tabular Text & Image …

Pandas Example – Write a Pandas program to extract the day name from a specified date

(Python Example for Beginners)   Write a Pandas program to extract the day name from a specified date. Add 2 days and 1 business day with the specified date.   Sample Solution: Python Code : import pandas as pd newday = pd.Timestamp(‘2020-02-07’) print(“First date:”) print(newday) print(“nThe day name of the said date:”) print(newday.day_name()) print(“nAdd 2 …

Pandas Example – Write a Pandas program to generate sequences of fixed-frequency dates and time spans intervals

(Python Example for Beginners)   Write a Pandas program to generate sequences of fixed-frequency dates and time spans intervals.   Sample Solution: Python Code : import pandas as pd print(“Sequences of fixed-frequency dates and time spans (1 H):n”) r1 = pd.date_range(‘2030-01-01′, periods=10, freq=’H’) print(r1) print(“nSequences of fixed-frequency dates and time spans (3 H):n”) r2 = …

Machine Learning Classification Algorithms in scikit learn package

(Machine Learning Classification Algorithms in scikit learn package) In this Learn through Codes example, you will learn Machine Learning Classification Algorithms in scikit learn package.  Python Example for Beginners Special 95% discount 2000+ Applied Machine Learning & Data Science Recipes Portfolio Projects for Aspiring Data Scientists: Tabular Text & Image Data Analytics as well …

Pandas Example – Write a Pandas program to create a time series object with a time zone

(Python Example for Beginners)   Write a Pandas program to create a time series object with a time zone.   Sample Solution: Python Code : import pandas as pd print(“Timezone: Europe/Berlin:”) print(“Using pytz:”) date_pytz = pd.Timestamp(‘2019-01-01’, tz = ‘Europe/Berlin’) print(date_pytz.tz) print(“Using dateutil:”) date_util = pd.Timestamp(‘2019-01-01’, tz = ‘dateutil/Europe/Berlin’) print(date_util.tz) print(“nUS/Pacific:”) print(“Using pytz:”) date_pytz = pd.Timestamp(‘2019-01-01’, …

Pandas Example – Write a Pandas program to check if a day is a business day (weekday) or not

(Python Example for Beginners)   Write a Pandas program to check if a day is a business day (weekday) or not.   Sample Solution: Python Code : import pandas as pd def is_business_day(date): return bool(len(pd.bdate_range(date, date))) print(“Check busines day or not?”) print(‘2020-12-01: ‘,is_business_day(‘2020-12-01’)) print(‘2020-12-06: ‘,is_business_day(‘2020-12-06’)) print(‘2020-12-07: ‘,is_business_day(‘2020-12-07’)) print(‘2020-12-08: ‘,is_business_day(‘2020-12-08’)) Sample Output: Check busines day or …

Pandas Example – Write a Pandas program to create a time series object that has time indexed data

(Python Example for Beginners)   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.   Sample Solution: Python Code : import pandas as pd index = pd.DatetimeIndex([‘2011-09-02’, ‘2012-08-04’, ‘2015-09-03’, ‘2010-08-04’, ‘2015-03-03’, ‘2011-08-04’, ‘2015-04-03’, ‘2012-08-04’]) s_dates …

Pandas Example – Write a Pandas program to print the day after and before a specified date

(Python Example for Beginners)   Write a Pandas program to print the day after and before a specified date. Also print the days between two given dates.   Sample Solution: Python Code : import pandas as pd import datetime from datetime import datetime, date today = datetime(2012, 10, 30) print(“Current date:”, today) tomorrow = today …

Pandas Example – Write a Pandas program to split a given dataset using group by on multiple columns and drop last n rows of from each group

(Python Example for Beginners)   Write a Pandas program to split a given dataset using group by on multiple columns and drop last n rows of from each group.   Test Data: ord_no purch_amt ord_date customer_id salesman_id 0 70001 150.50 2012-10-05 3002 5002 1 70009 270.65 2012-09-10 3001 5003 2 70002 65.26 2012-10-05 3001 5001 …