<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shubham Birhade on Medium]]></title>
        <description><![CDATA[Stories by Shubham Birhade on Medium]]></description>
        <link>https://medium.com/@shubhambirhade?source=rss-6ed2bc9bc4f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_Iai7h0AXj7D_WWz</url>
            <title>Stories by Shubham Birhade on Medium</title>
            <link>https://medium.com/@shubhambirhade?source=rss-6ed2bc9bc4f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:46:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhambirhade/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python program to print table of user choice]]></title>
            <link>https://medium.com/@shubhambirhade/python-program-to-print-table-of-user-choice-945978be7c88?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/945978be7c88</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Sun, 24 Mar 2024 15:14:17 GMT</pubDate>
            <atom:updated>2024-03-24T15:14:17.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*muEzU61TjCxQ-Qj3u4kQLA.png" /><figcaption>tables</figcaption></figure><p>Hello learners, today we are going to learn how we can print table of any number of user choice.</p><p>First we will take user input as shown below</p><pre>table_to_print = int(input(&#39;enter number which table you want to print&#39;))</pre><blockquote>as shown above we have stored number value in variable <strong><em>table_to_print</em></strong></blockquote><p>The complete code to print table is as below</p><pre>n = int(input(&#39;enter number which table you want to print&#39;))<br><br>for i in range(1, 11):<br>    print(i*n)</pre><p>the output for above code is as below</p><pre>enter number which table you want to print : 2<br>2<br>4<br>6<br>8<br>10<br>12<br>14<br>16<br>18<br>20</pre><p>As shown above we can print table of any number of user choice.</p><p>If you find this article helpful do share and follow for more updates.</p><p>Thank you!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=945978be7c88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python program to check number is odd or even]]></title>
            <link>https://medium.com/@shubhambirhade/python-program-to-check-number-is-odd-or-even-1d9edaa142dc?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d9edaa142dc</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python-developers]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Sun, 24 Mar 2024 14:50:49 GMT</pubDate>
            <atom:updated>2024-03-24T14:50:49.201Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*rlF1M2_XsDjAxSqYrVAvhg.jpeg" /><figcaption>odd and even numbers in python</figcaption></figure><p>Hello learners, today we are going to see basic python program to find given number is odd or even.</p><p>first of all we will take input from user and we will make input as type int as shown below:</p><pre>number = int(input(&#39;enter number&#39;))</pre><p>Now we will focus on logic part.</p><p>If number is divisible by 2 and remainder is 0 then we will consider that number as even number. Example as shown below.</p><pre>number = 24<br>if number%2==0:<br>    print(&#39;even number&#39;)<br><br>else:<br>    print(&#39;odd number&#39;)<br><br># output will be <br>-&gt; number is even number</pre><p>If number is not divisible by 2 then we will consider that number as odd number. Example as shown below.</p><pre>number = 23<br>if number%2==0:<br>    print(&#39;even number&#39;)<br><br>else:<br>    print(&#39;odd number&#39;)<br><br># output will be <br>-&gt; odd number</pre><p>As you seen above we checked given number is odd or even.</p><p>If you find this helpful please follow and share with other learners.</p><p>Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d9edaa142dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple calculator program using Python]]></title>
            <link>https://medium.com/@shubhambirhade/simple-calculator-program-using-python-ff1bfac69a29?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff1bfac69a29</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[operators-in-python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Wed, 08 Jun 2022 14:57:32 GMT</pubDate>
            <atom:updated>2022-06-08T14:57:32.566Z</atom:updated>
            <content:encoded><![CDATA[<p>In this example we are going to see how we can make calculator program which can add, subtract, divide, multiply also which takes input from user python .</p><p>First we will create two variables which takes values from user as input. In this we are going to use in-built function <strong>‘input’.</strong></p><p><strong>num1 = int(input(‘enter first number: ’))</strong></p><p><strong>num2 = int(input(‘enter second number: ’))</strong></p><p>Now we will ask user for which arithmatic operation he wants to do? For that we will create another input variable.</p><p><strong>operation = input(‘select operator (+, -, *, /, %) : ’)</strong></p><p>Now we can make use of <strong>‘if-elif-else’</strong> condition in our program.</p><p><strong><em>if </em>operation<em>== ‘+’:</em></strong></p><p><strong><em>print(num1+num2)</em></strong></p><p><strong><em>elif </em>operation<em>== ‘-’:</em></strong></p><p><strong><em>print(num1-num2)</em></strong></p><p><strong><em>elif </em>operation<em>== ‘*’:</em></strong></p><p><strong><em>print(num1*num2)</em></strong></p><p><strong><em>elif </em>operation<em>== ‘/’:</em></strong></p><p><strong><em>print(num1/num2)</em></strong></p><p><strong><em>elif </em>operation<em>== ‘%’:</em></strong></p><p><strong><em>print(num1%num2)</em></strong></p><p><strong><em>else:</em></strong></p><p><strong><em>print(‘thank you’)</em></strong></p><p>In above program we ask user for input and based on input value and operation output gets generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*hTcPuM0cS6Fgq-raAMaM3g.png" /><figcaption>in above snippet you can find my code for calculator program.</figcaption></figure><p>I hope you have enjoyed above tutorial.</p><p>If you find the above article useful please <strong>follow me and clap for this article.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*GzvecG_5o73rm_pHsm1Lbw.jpeg" /></figure><p><strong><em>Connect</em> </strong>with me on <strong>LinkedIn</strong> and follow for such amazing articles</p><p><a href="https://www.linkedin.com/in/shubham-birhade-87bb7b1a2/"><strong>https://www.linkedin.com/in/shubham-birhade-87bb7b1a2</strong></a></p><p>Also if you want read my articles please click on below link</p><p><a href="https://medium.com/@shubhambirhade/list/reading-list"><strong>https://medium.com/@shubhambirhade/list/reading-list</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff1bfac69a29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Download YouTube video using Python in just 4 lines of code]]></title>
            <link>https://medium.com/@shubhambirhade/download-youtube-video-using-python-in-just-4-lines-of-code-2b248cb0da2a?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b248cb0da2a</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[application]]></category>
            <category><![CDATA[future]]></category>
            <category><![CDATA[youtube]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Mon, 16 May 2022 15:21:47 GMT</pubDate>
            <atom:updated>2022-05-16T15:21:47.725Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*wf_B5uPt5mUHxldq4bFcpQ.png" /></figure><p>In this tutorial we are going to see how we can download you tube video using Python.</p><p>For this tutorial we are using <strong><em>pytube </em></strong>library.</p><blockquote>We will download pytube as <strong>pip install pytube</strong></blockquote><p>First of all we will import pytube library as follows</p><p><strong>from pytube import YouTube</strong></p><p>Now we will provide url link of you tube video as follows</p><p><strong>video_link = ‘</strong><a href="https://www.youtube.com/watch?v=3qQzwOY13zY"><strong>https://www.youtube.com/watch?v=3qQzwOY13zY</strong></a><strong>’</strong></p><p>Now we will pass variable link to YouTube function</p><p><strong>video = YouTube(video_link)</strong></p><p>Now we will download video as follows:</p><p><strong>video.streams.filter(res=’720p’).first().download(‘C:/Users/shubh/OneDrive/Desktop/func’)</strong></p><p>If you find the above article useful please <strong>follow me and clap for this article.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*J_se5k0HcwljBIgEmsoNOA.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b248cb0da2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[List in Python (Part-1)]]></title>
            <link>https://medium.com/@shubhambirhade/list-in-python-part-1-28ce361f9543?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/28ce361f9543</guid>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Sat, 14 May 2022 11:28:39 GMT</pubDate>
            <atom:updated>2022-05-14T11:28:39.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/309/1*3onOTtFmR5c8hyBKQsG21w.jpeg" /></figure><p>In this tutorial we will learn some basics about python list.</p><p>Python list allow us to work with different types of elements at once.</p><p><strong>list1 = [ ‘hello’, ‘world’, ‘python’, ‘list’]</strong> #this is example of list</p><p>List is created by placing elements inside <strong>[ element1, element2, element3]</strong> square brackets.</p><ol><li>Lets create list of integers</li></ol><p><strong>int_list = [1, 2, 3, 4, 5]</strong></p><p>2. Lets create list of floats</p><p><strong>float_list = [1.25, 2.87, 3.74, 4.15, 5.85]</strong></p><p>3.) Lets create list of string</p><p><strong>str_list = [ ‘hello’, ‘world’, ‘python’, ‘learning’]</strong></p><p>4.) Lets create list of mixed data type</p><p><strong>mix_list = [ ‘hello’, 123, 78.63, ‘python’ , 57, 47.21]</strong></p><p>5.)Lets create empty list</p><p><strong>empty_list = []</strong></p><p>6.) Lets create <strong>nested list</strong></p><p><strong>Nested list means list inside list</strong></p><p><strong>nest_list = [23, 56, ‘hello’, 4.6, [8.9, ‘python’]]</strong></p><p>Till now we have created list of different data types. Now we are going to see how to access list elements?</p><p><strong>Accessing list elements</strong></p><p>There are various ways to access elements inside list. As we know that in python indexing starts from 0, so if index having 5 elements indexing starts from 0 to 4. In following example we will see how to access elements inside list.</p><p><strong>my_list = [ ‘python’, ‘is’, ‘popular’, ‘language’]</strong></p><p>Now lets access element at <strong>index 0.</strong></p><p><strong>my_list[0] = ‘python’</strong></p><p>Now lets access element at <strong>index 2.</strong></p><p><strong>my_list[2] = ‘popular’</strong></p><p>Now lets access last element of list. In this case we use negative indexing.</p><p><strong>my_list[-1] = ‘language’</strong></p><p>In above example <strong>[-1] </strong>shows element at last place or last index.</p><p>Now lets see about <strong>Nested List</strong></p><p><strong>nest_list = [‘good’, ‘morning’, [‘tea’, ‘coffee’]]</strong></p><p><strong>Nested list indexing</strong></p><p>Now lets get <strong>‘tea’ </strong>value from above nested list</p><p><strong>ans = nest_list[2][0]</strong></p><p><strong>ans = ‘tea’</strong></p><p>lets get <strong>‘coffee’ </strong>value from above nested list</p><p><strong>ans_2 = nest_list[2][1]</strong></p><p><strong>ans_2 = ‘coffee’</strong></p><blockquote>One point keep in mind always is <strong>only integer is used while indexing.</strong></blockquote><p>If you have any queries or suggestions please feel free to ask.</p><p>If you find the above article useful please <strong>follow me and share to data science enthusiasts</strong>. <strong>Lets spread the knowledge</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/0*erszOZK1ztGdY67B.jpeg" /></figure><p>Reference:</p><ol><li><a href="https://docs.python.org/3/tutorial/datastructures.html">https://docs.python.org/3/tutorial/datastructures.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28ce361f9543" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Pandas DataFrame using Dictionary in Python]]></title>
            <link>https://medium.com/@shubhambirhade/create-pandas-dataframe-using-dictionary-in-python-38851eb52398?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/38851eb52398</guid>
            <category><![CDATA[dictionary]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[dataframes]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Sat, 14 May 2022 03:14:02 GMT</pubDate>
            <atom:updated>2022-05-14T03:14:32.284Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*n4wBi8lrpS8td2-aRhoyuw.png" /></figure><p>Till now we have seen that we have created dataframe by reading csv file using <strong>‘read_csv’</strong> method.</p><p>Now we are going to see how we can make dataframe using dictionary in python.</p><p><strong>data = {‘computer’: 15000, ‘laptop’ : 40000, ‘cpu’: 18500, ‘keyboard’: 1200}</strong></p><p>In above dictionary i have provided key as product name and value as product price.</p><p>Now we are calling <strong>pd.DataFrame()</strong> class to combine above keys and values together to form a DataFrame.</p><p><strong>df = pd.DataFrame(list(data.items()), columns=[‘product_name’, ‘product_price’])</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*WOBELeXtO0n6vhBWgoll_A.png" /></figure><p>In the above image we can see that we have created dataframe from dictionary</p><p>We can check datatype of df as follows:</p><p><strong>print(type(df))</strong></p><p><strong>— &gt; &lt;class ‘pandas.core.frame.DataFrame’&gt;</strong></p><p>This way you will get.</p><p>If you have any queries or suggestions please feel free to ask.</p><p>If you find the above article useful please <strong>follow me and share</strong> to data science enthusiasts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*J_se5k0HcwljBIgEmsoNOA.jpeg" /></figure><p>Reference:</p><ol><li><a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html">https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38851eb52398" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Datetime formats in Python (Part-1)]]></title>
            <link>https://medium.com/@shubhambirhade/datetime-formats-in-python-part-1-fd874f54586?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd874f54586</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Fri, 13 May 2022 16:06:35 GMT</pubDate>
            <atom:updated>2022-05-13T16:06:35.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*c2FTBGSYtgzW098BpUxK5Q.png" /></figure><p>In this article, we will go through how to convert date, time and datetime objects to its equivalent string.</p><p>First of we will import datetime module as follows :</p><p><strong>from datetime import datetime</strong></p><ol><li>How to get current day ?</li></ol><p><strong>current_day = now.strftime(“%d”)</strong><br>current_day = 13</p><p>2. How to get current month ?</p><p><strong>current_month = now.strftime(“%m”)</strong><br>current_month = 05</p><p>3. How to get current year ?</p><p><strong>current_year = now.strftime(“%Y”)</strong><br>current_year= 2022</p><p>4. How to get current time ?</p><p><strong>current_time = now.strftime(“%H:%M:%S”)</strong><br>current_time= 21:23:01</p><p>5. How to get current date and time ?</p><p><strong>date_time = now.strftime(“%m/%d/%Y, %H:%M:%S”)</strong><br>date_time = 05/13/2022, 21:29:43</p><p>In this tutorial we learn how to work with basic datetime formats in python.</p><p>In the next part we will learn more functions of datetime formats.</p><p>If you have any queries or suggestions please feel free to ask.</p><p>If you like the above article please <strong>follow me and share to data science enthusiasts.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*KjN82YzD3NCU9N9sXz4LVw.jpeg" /></figure><p>Reference:</p><ol><li><a href="https://docs.python.org/3/library/datetime.html">https://docs.python.org/3/library/datetime.html</a></li><li><a href="https://www.tutorialkart.com/python/python-datetime/python-datetime-format/">https://www.tutorialkart.com/python/python-datetime/python-datetime-format/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd874f54586" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playing with Datetime module in Python.]]></title>
            <link>https://medium.com/@shubhambirhade/playing-with-datetime-module-in-python-9afb6e1aaea8?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9afb6e1aaea8</guid>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[datetime]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Wed, 11 May 2022 15:05:24 GMT</pubDate>
            <atom:updated>2022-05-11T15:05:24.664Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*3wxDNCKsapbRf7GR8-avTg.png" /></figure><p>Python has a module named <strong>datetime</strong> to work with dates and times. The datetime module supplies classes for manipulating dates and times.</p><p>Below is the link to download the dataset for this tutorial.</p><p><a href="https://github.com/ShubhamBirhade1/time_series_data.git">GitHub - ShubhamBirhade1/time_series_data</a></p><p>1.) First we will import our pandas and datetime module as follows:</p><p><strong>import pandas as pd</strong></p><p><strong>from datetime import datetime</strong></p><p>Now we will read our csv file as follows</p><p>df=pd.read_csv(‘C:/date_time_data_file.csv’)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*5blj0AbPsWazGSeUWnsGhg.png" /><figcaption>this is our current dataframe</figcaption></figure><p>2.) Get dates separeted from date_time column using datetime module.</p><p><strong>df[‘date’] = pd.to_datetime(df[‘date_time’]).dt.date</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*4ortQ8H7WPV2GSOKT1WEIg.png" /></figure><p>In date column we only get dates values from ‘date_time’ column.</p><p>3.) Get time separeted from date_time column using datetime module.</p><p><strong>df[‘time’] = pd.to_datetime(df[‘date_time’]).dt.time</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*cTcjTHk-qG-mHwt9b4jluw.png" /></figure><p>In time column we only get time values from ‘date_time’ column.</p><p>4.) Get year seprated from date_time column.</p><p><strong>df[‘year’] = pd.to_datetime(df[‘date_time’]).dt.year</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*JV6l1LpV4PiojLHwE3vrSA.png" /><figcaption>year column seprated from date_time column</figcaption></figure><p>5) Get month seprated from date_time column</p><p><strong>df[‘month’] = pd.to_datetime(df[‘date’]).dt.month</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*j4lQIFaZTdiWyezC7ap3cw.png" /><figcaption>month number is seprated from date_time column</figcaption></figure><p>6) Get day column seprated from date_time column</p><p><strong>df[‘day’] = pd.to_datetime(df[‘date’]).dt.day</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*yl0Xezj1g9se0c0muq0UzA.png" /><figcaption>day is seprated from date_time column</figcaption></figure><p>7.) Get name of weekday</p><p><strong>df[‘weekday’] = pd.to_datetime(df[‘date’]).dt.day_name()</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*GOh6SBoCu-8Efc1QBCX4YA.png" /><figcaption>weekday column added at the end</figcaption></figure><p>8) Get name of month using <strong>calendar </strong>and <strong>datetime </strong>module</p><p><strong>import calendar<br>df[‘monthName’] = df[‘month’].apply(lambda x: calendar.month_name[x])</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*1q7jtUEaXh_w4VXpXSaCvg.png" /><figcaption>month name column added at the end of dataframe</figcaption></figure><p>If you find this article of datetime module helpful please do share to data enthusiasts and follow me for more such helpful tutorials.</p><p>If you have any queries or suggestion please feel free to ask.</p><p><strong>connect with me on linkedin:</strong></p><p><a href="https://www.linkedin.com/in/shubham-birhade-87bb7b1a2/">https://www.linkedin.com/in/shubham-birhade-87bb7b1a2/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*J_se5k0HcwljBIgEmsoNOA.jpeg" /></figure><p>References:</p><ol><li><a href="https://stackoverflow.com/questions/6557553/get-month-name-from-number">https://stackoverflow.com/questions/6557553/get-month-name-from-number</a></li><li><a href="https://stackoverflow.com/questions/28009370/get-weekday-day-of-week-for-datetime-column-of-dataframe">https://stackoverflow.com/questions/28009370/get-weekday-day-of-week-for-datetime-column-of-dataframe</a></li><li><a href="https://docs.python.org/3/library/datetime.html">https://docs.python.org/3/library/datetime.html</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9afb6e1aaea8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Select columns and rows in pandas Dataframe.]]></title>
            <link>https://medium.com/@shubhambirhade/select-columns-and-rows-in-pandas-dataframe-817ead8d3939?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/817ead8d3939</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Tue, 03 May 2022 11:22:24 GMT</pubDate>
            <atom:updated>2022-05-03T11:40:00.656Z</atom:updated>
            <content:encoded><![CDATA[<p>For this tutorial we are using same dataset which we have used in earlier two parts you can check here <a href="https://medium.com/@shubhambirhade/fun-with-pandas-a-perfect-data-analysis-tool-part-1-3fd12dea7bb7">https://medium.com/@shubhambirhade/fun-with-pandas-a-perfect-data-analysis-tool-part-1-3fd12dea7bb7</a>,</p><p>You can download dataset from below github link.</p><p><a href="https://github.com/ShubhamBirhade1/student_data/blob/16ece0d167135877e7cf51ca62d31c28105a780d/student_data.csv">student_data/student_data.csv at 16ece0d167135877e7cf51ca62d31c28105a780d · ShubhamBirhade1/student_data</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*nKya5-d7eADSd3sVy1ISPw.jpeg" /></figure><ol><li><strong>How to select specific columns in Dataframe?</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*oqUe7a4GDYjBz281vCpRqQ.png" /><figcaption>this dataframe contains all columns</figcaption></figure><p>If you have large number of columns and in a particular case you want to deal only with specific columns of dataframe then you can do following operation:</p><p>new_df = df[[‘specific_col_1’, ‘specific_col_2’, ‘specific_col_3’]]</p><p><strong>select_cols_df = df[[ ‘student_name’ , ‘chemistry’ , ‘physics’ , ‘maths’ ]]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*9yB8mhO5HUJa5UREA6ZDZg.png" /><figcaption>after selecting specific columns</figcaption></figure><p><strong>2. Select columns in dataframe based on index location</strong></p><p>In this example we are selecting columns at index location 0,1,2,3</p><p><strong>selc_indx_col = df.iloc[: , [0,1,2,3]]</strong></p><p>In above syntax inside square brackets <strong>[ :</strong> means we are selecting all rows of specified columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*2FlVmZqcX_WmE1MFghQgvQ.png" /><figcaption>select columns based on index location</figcaption></figure><p><strong>3. Select rows in pandas dataframe using loc method</strong></p><p><strong>Example 1:</strong> In this example we are selecting rows where ‘age’ = 22</p><p>The syntax is as follows for selecting rows using loc method:</p><p><strong>sel_row = df.loc[df[‘age’] == 22]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*fuBZ1t8ZpFvzsVTC5rttmg.png" /><figcaption>we are selected rows where age = 22</figcaption></figure><p><strong>Example 2 : </strong>In this example we are selecting rows where</p><p>chemistry marks = 78</p><p>The syntax is as follows for selecting rows using loc method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*ax_s8MeOQfWrOaCp-dGHww.png" /><figcaption>rows where chemistry marks = 78</figcaption></figure><p><strong>4. Select row using iloc method (select row using index location)</strong></p><p>To select row at specific index location we use iloc method. It returns row at that specific location</p><p><strong>Example 1:</strong> In this example we are selecting row at index location 5. In following syntax we are providing index location in sqaure barckets.</p><p><strong>row_idx = df.iloc[5]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*wiHLthsWCrqcAp7opvuSdg.png" /><figcaption>selected 5th index row using iloc method</figcaption></figure><p>Example 2: In this example we are selecting last row of dataframe using negative indexing.</p><p><strong>last_row = df.iloc[-1]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*5TqcCuoOagpm9RreC4VYGg.png" /><figcaption>selected last row of dataframe using iloc method</figcaption></figure><p><strong>5. Select rows based on condition</strong></p><p>In this example we are selecting rows where physics marks are greater than 75.</p><p><strong>phy_df = df[df[ ‘physics’ ] &gt; 75]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*iObv4LXHtKzL8iBe_m7Pnw.png" /><figcaption>we selected rows where physics marks are greater than 75</figcaption></figure><p>If you have any queries or suggestions please feel free to ask.</p><p>If you find the above article useful please follow me and share to data science enthusiasts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*KjN82YzD3NCU9N9sXz4LVw.jpeg" /></figure><p>References:</p><ol><li><a href="https://www.geeksforgeeks.org/selecting-rows-in-pandas-dataframe-based-on-conditions/">https://www.geeksforgeeks.org/selecting-rows-in-pandas-dataframe-based-on-conditions/</a></li><li><a href="https://www.machinelearningplus.com/pandas/pandas-iloc-how-to-select-rows-using-index-in-dataframes/">https://www.machinelearningplus.com/pandas/pandas-iloc-how-to-select-rows-using-index-in-dataframes/</a></li><li><a href="https://www.statology.org/pandas-select-column-by-index/#:~:text=Often%20you%20may%20want%20to,indexing%2C%20you%20can%20use%20the%20">https://www.statology.org/pandas-select-column-by-index/#:~:text=Often%20you%20may%20want%20to,indexing%2C%20you%20can%20use%20the%20</a>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=817ead8d3939" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fun with pandas a perfect data analysis tool.(Part -2)]]></title>
            <link>https://medium.com/@shubhambirhade/fun-with-pandas-a-perfect-data-analysis-tool-part-2-6f9d5332beac?source=rss-6ed2bc9bc4f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f9d5332beac</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Shubham Birhade]]></dc:creator>
            <pubDate>Tue, 03 May 2022 06:37:21 GMT</pubDate>
            <atom:updated>2022-05-03T06:37:21.419Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last tutorial we have seen how to read a csv file and some built-in functions of pandas.</p><p>You can check previous article in below link</p><p><a href="https://medium.com/@shubhambirhade/fun-with-pandas-a-perfect-data-analysis-tool-part-1-3fd12dea7bb7">Fun with pandas a perfect data analysis tool.(Part -1)</a></p><p>In this tutorial we are going to see how to drop a column and row from dataframe also how to add a column and row in dataframe.</p><ol><li><strong>How to drop a single column from dataframe?</strong></li></ol><p>In this example we are going to drop a <strong>‘city’ </strong>column from dataframe.</p><p>before dropping the column first lets see our dataframe</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*WlMbktf5OdrPiL7eO7ml7g.png" /><figcaption>before dropping column from dataframe</figcaption></figure><p>the syntax for dropping the column from dataframe is as follows:</p><pre>df.drop(&#39;column_name&#39;, axis=1, inplace=True)  </pre><p><strong>df.drop( ‘city’ , axis=1 , inplace=True)</strong></p><p>In above syntax, <strong>axis=1</strong> means that we are dropping column and</p><p><strong>inplace = True</strong> means we are going to make changes in original dataframe.</p><p>Also if we do not want to make changes in original dataframe then we can do new_df = df.drop(df.columns[1], axis=1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*fv2KiH1kKBtbCT_MIbFVow.png" /><figcaption>without writing inplace = True in syntax we can save changes in another dataframe</figcaption></figure><p>This will not make any changes to original dataframe and makes changes in another dataframe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*VsBVamO4ia96_1IiKg8slQ.png" /><figcaption>after dropping the ‘city’ column from dataframe we get above dataframe</figcaption></figure><p><strong>2. How to drop multiple columns from dataframe?</strong></p><p>To drop multiple columns from dataframe we pass name of columns in list.</p><p>In our example we are going to drop all subject columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*MQleKRBUUVu0tuJWXFSwNQ.png" /><figcaption>before dropping subject columns from dataframe</figcaption></figure><p>the syntax for dropping the multiple columns from dataframe is as follows:</p><pre>df.drop([&#39;column_name1&#39;, &#39;column_name2&#39;], axis=1, inplace=True)</pre><p><strong>df.drop( [ ‘chemistry’ , ‘physics’ , ‘maths’ ], axis=1 , inplace=True )</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*yozyIjP2f29YT7Kvc3yGHQ.png" /><figcaption>after dropping multiple columns from dataframe</figcaption></figure><p><strong>3. How to Drop column based on index location?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*8LVjHR6JtC2oDo92LsrHAw.png" /><figcaption>before dropping column at index location 1</figcaption></figure><p>In above step we can see that we have dropped the column at index location 1.</p><p>The syntax for dropping the column at specific index location is as follows:</p><pre>df.drop(df.columns[1], axis=1, inplace=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*gcHcP4e9YOGyNATGLYhDKQ.png" /><figcaption>after dropping column at index location 1</figcaption></figure><p><strong>4. How to drop rows from dataframe?</strong></p><p>In this example we are going to drop rows where age is <strong>20.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*GoIYIf41wQ2q8GP1lCrUEA.png" /><figcaption>before dropping rows at index number 7 and 9</figcaption></figure><p>In this case we are going to drop rows based on index value. Now are going to drop row at index number 7 and 9.</p><p>To drop rows based on index the syntax is as follows.</p><p><strong>df1 = df.drop( index=[7,9], axis=0 , inplace=True )</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*k31LkFUfXXDhLUPemJkRWg.png" /><figcaption>after dropping rows at index number 7 and 9</figcaption></figure><p><strong>5. Insert a column in dataframe</strong></p><p>To insert a column in a datframe is quite easy. The syntax is as follows:</p><p>df[‘new_column_name’] = [ ‘item1’, ‘item2’, ‘item3’]</p><p>In above syntax we pass name of row for newly inserted data in list. The list items are equal to length of dataframe</p><p><strong>df[‘favourite_game’] = [‘cricket’, ‘foot_ball’, ‘swimming’, ‘base_ball’, ‘vollyball’, ‘running’ , ‘cycling’, ‘carrom’, ‘high_jump’, ‘long_jump’]</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*FZTXVsqOsmfouQ4KtmQvng.png" /><figcaption>after inserting new column in dataframe</figcaption></figure><p>We can see newly inserted column in dataframe at the end.</p><p><strong>6. Insert column at specific index location in dataframe</strong></p><p>favourite_game = [‘cricket’, ‘foot_ball’, ‘swimming’, ‘base_ball’, ‘vollyball’, ‘running’ , ‘cycling’, ‘carrom’, ‘high_jump’, ‘long_jump’]</p><p>In above list we are passing row items.</p><p>The syntax for inserting a column at specific location is as follows:</p><p><strong>df.insert(loc = 1, column = ‘favourite_game’ , value = favourite_game)</strong></p><p>in above syntax <strong>loc = 1</strong> is the index location where we are inserting a column,</p><p><strong>column = ‘favourite_game’</strong> is the name of newly inserted column,</p><p><strong>value = favourite_game </strong>is the list of rows for newly inserted column.</p><p>The value can be dataframe column also.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*1Dp3gLP32tl-w0XUg8RnVA.png" /><figcaption>we can see new column is inserted at index location 1</figcaption></figure><p><strong>7. Insert row in existing dataframe using append method.</strong></p><p>In this method we are using dictionary so that we can append it to existing dataframe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*xxPm3SzmydL4p4A2SVPgnw.png" /><figcaption>before inserting new row at end</figcaption></figure><p>The syntax is as follows:</p><p>df2 <strong>=</strong> {&#39;col1&#39;: &#39;val1&#39;, &#39;col2&#39;: &#39;val2, &#39;col3&#39;: val3}</p><p>new_row = {‘student_name’: ‘Amy’, ‘favourite_game’ : ‘hockey’ , ‘age’: 19, ‘city’: “yawal”, ‘chemistry’: 78 , ‘physics’ : 96, ‘maths’ : 73}</p><p><strong>df = df.append(new_row, ignore_index = True)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*8DzKTLuXfdVBsgd3GOKi5A.png" /><figcaption>after inserting new row at end</figcaption></figure><p>In this tutorial we have covered dropping row and column as well as inserting column and row.</p><p>If you find this article useful please follow me for more such articles.</p><p>Thanks.</p><p>References:</p><ol><li><a href="https://www.geeksforgeeks.org/how-to-add-one-row-in-an-existing-pandas-dataframe/">https://www.geeksforgeeks.org/how-to-add-one-row-in-an-existing-pandas-dataframe/</a></li><li><a href="https://stackoverflow.com/questions/20297317/python-dataframe-pandas-drop-column-using-int">https://stackoverflow.com/questions/20297317/python-dataframe-pandas-drop-column-using-int</a></li><li><a href="https://www.geeksforgeeks.org/insert-a-given-column-at-a-specific-position-in-a-pandas-dataframe/">https://www.geeksforgeeks.org/insert-a-given-column-at-a-specific-position-in-a-pandas-dataframe/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f9d5332beac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>