<?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 Anshi Choudhary on Medium]]></title>
        <description><![CDATA[Stories by Anshi Choudhary on Medium]]></description>
        <link>https://medium.com/@acanshi277?source=rss-de5360c1895c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Anshi Choudhary on Medium</title>
            <link>https://medium.com/@acanshi277?source=rss-de5360c1895c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:06:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@acanshi277/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[Financial Trading in Python for beginner Day-2]]></title>
            <link>https://medium.com/@acanshi277/financial-trading-in-python-for-beginner-day-2-92d9499b7e30?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/92d9499b7e30</guid>
            <category><![CDATA[financial-analysis]]></category>
            <category><![CDATA[python-in-finance]]></category>
            <category><![CDATA[financial-analyst-skill]]></category>
            <category><![CDATA[financial-analyst-course]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Thu, 05 Sep 2024 12:03:41 GMT</pubDate>
            <atom:updated>2024-09-05T12:03:41.778Z</atom:updated>
            <content:encoded><![CDATA[<p>In this episode we will explore how to use Python to get more familiar with your trading data. We can categorize traders into a few types by how long they hold their trading positions, that is their holding periods.</p><ol><li><strong>Day Trader</strong>: hold their positions throughout the day but usually not overnight. they tend to trade frequently.</li><li><strong>Swing Trader</strong>: holds positions from a few days to several weeks.</li><li><strong>Position Trader</strong>: holds positions from a few months to several years.</li></ol><p><strong>Resample the data:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*6W3XOoY-v3A9fblinuZFqQ.png" /></figure><p>Depending on the trading style you may want to look at the time series data from different intervals, such as hourly, daily, weekly etc.</p><p>For example, a swing trader would prefer to have a daily price snapshot instead of one for every hour.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*W3-WVO6BiWaC9fnW1or8iw.png" /></figure><p>You can use the resample method to sample a Python DataFrame. The code here demonstrates how to resample hourly data to daily or weekly data by specifying the parameter to be the “D” and “W” in “resample” respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*tYKwNl4ToXCzRoEo3s_E2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*Nwbfp22hTIzqWAvakHT3nQ.png" /></figure><p>Typically we downsample from a narrower time frame to a wider time frame such as hourly to daily. This will result in a fewer number of rows and the sampled data of the wider time frame is the aggregated result of the lower time frame. In this case, we use the mean, but it can also be the minimum, maximum, or the sum.</p><p><strong>Calculating the daily returns:</strong></p><p>It is also helpful to get familiar with your trading data by checking past returns and volatility. For example we can use the pct_change() method to calculate percentage change in the price also known as price return. It computes the percentage change from the preceding row by default, so if we use daily price data, we will get daily returns. By plotting the results, we can obtain a quick understanding of the typical return ranges and the volatility profile of a financial asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*tu4BO04CL0VPR2E1NTQODg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*HWEGOWcKCD2iVMzZ_g6YYA.png" /></figure><p><strong>Plot a histogram of daily returns:-</strong></p><p>It is helpful to plot a histogram of daily price returns. A histogram is a visual representation of the distribution of the underlying data. To plot a histogram in Python we call the “hist” method on a Dataframe column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SvfiLcLXmHuuWwKElItAzQ.png" /></figure><p>You can use “bins” to specify how granular you want the chart to be.</p><p><strong>Data Transformation:</strong></p><p>The financial market reflects fear, greed and human behavior biases hence the market data is inherently noisy and messy. To make sense of the data, traders perform various data transformations and create so-called technical indicators.</p><p>Technical indicators: various types of data transformations.</p><p>A very common indicators is the simple moving average or SMA. It is simply the arithmetic mean of the price over a specified period. The average is called “moving” because it is always calculated using the most recent n period and therefore moves along with the price on the chart. The SMA can be easily calculated using “ .rolling().mean() on the price column and specify the averaging period with the argument “window=n”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VRw_hWChbRmHZuKXk0mmbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*A9XyaOgJJm-Ps-rmEp_emQ.png" /></figure><p>We can plot the SMA and the price in one chart. The plot includes a legend and shows that the moving average has a smoothing effect on the price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2G6kYkVYYXnfi05Clyj-Bw.png" /></figure><p>There is a rich library of technical indicators developed for trading. We will explore more details about this in upcoming episode.</p><p>Till then bye see in the next episode</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92d9499b7e30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Financial Trading in Python for beginner Day-1]]></title>
            <link>https://medium.com/@acanshi277/financial-trading-in-python-for-beginner-day-1-3d3c5833e0b0?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d3c5833e0b0</guid>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[financial-analysis]]></category>
            <category><![CDATA[python-finance]]></category>
            <category><![CDATA[python-in-finance]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 11:45:07 GMT</pubDate>
            <atom:updated>2024-09-04T11:45:07.199Z</atom:updated>
            <content:encoded><![CDATA[<p>Finance and python are two most popular name in today’s job world and by joining them together you can wonders. So, here I come with another series of Python with finance, it will be really helpful for those who wants to learn financial analysis and finance aspect from an engineering background or have no or little knowledge of finance. It is a beginner level course.</p><p>We will discuss why people trade, what the different trading styles are, and how to use python to implement and test your trading strategies, indicators, and signals and many more. Let’s start</p><h3><strong>Trading Basics:</strong></h3><p><strong>What is financial trading?</strong></p><p>Financial trading is the buying and selling of financial assets, also called financial securities.</p><p>Various financial instruments to trade: — People trade a variety of financial instruments including</p><ol><li>Equities — shares of stock representing ownership of companies</li><li>Bonds — debt instruments issued by the government or corporations.</li><li>Forex — foreign exchange market of currencies.</li><li>Commodities — such as gold, silver, and oil.</li><li>Cryptocurrencies like bitcoin.</li></ol><h3><strong>Why People trade?</strong></h3><p>People trade to make a profit by taking calculates risks.</p><ol><li>Long positions: — (profits from upward price movement) a trader makes a profit when buying a security at a lower and selling later at a higher price, known as going long</li><li>Short positions: —(profit from downward price movement) Conversely, they may sell a (borrowed) security at a higher and buy it back at a lower price, known as going short.</li></ol><p>Market Participants:</p><ol><li>Institutional traders: — Institutional traders such as hedge funds or investment banks, may trade in order to hedge financial risks, provide market liquidity, or re- balance their portfolios.</li><li>Retail traders: — Retail traders are mostly trading for their own accounts sometimes as a side hustle</li></ol><h3>Trading vs Investing</h3><p>The main difference between <strong>trading</strong> and <strong>investing</strong> is time-horizon.</p><p>Trading</p><ol><li>Shorter holding period ranging from days to months.</li><li>Focus on short- term trends and tries to profit from volatility and price fluctuations.</li><li>Take both long and short positions in order to profit from both upward and downward price movement.</li></ol><p>Investing</p><ol><li>Longer holding period ranging up to years or even decades.</li><li>Focus on market fundamentals, macroeconomic environment, and aims to ride on big trends that can span years.</li><li>Take mostly long positions.</li></ol><p>In this series we will focus on technical analysis based financial trading. Generally a technical trader analyzes historical patterns of trading data, and implements trading strategies based on indicators, signals, and rules in order to profit from possible future price movement.</p><h3><strong>Financial time series data</strong></h3><p>For financial trading we mostly work with time series data of security prices.</p><p>Time series data: a sequence of data points indexed in time order. <br>Here we have some bitcoin historical price data saved in a csv file. we load it as a dataframe with the read.csv function from pandas which has been imported as pd.<br>We use index_col=’Date’<br>as the index and set parse_dates = True to parse the index in DateTime format and head method display the top 5 rows of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*4ZD_0yjzA1rrMezl6TT87g.png" /></figure><p>We can plot the time series data with plot function using the matplotlib show function to display the plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*gK1mDbBUUOYu9K0iDI2BtQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lN_iD-uiB5PTRHzZQmuS2w.png" /></figure><p>The resulting line chart gives us information on past price patterns</p><p>We can also visualize the price movement using a candlestick chart</p><p><strong>CANDLESTICK CHART</strong></p><p>Each candlestick shows price information for one- period for example one-day within each candle we can see: open and close in the candle body and high and high and low in the candlewick</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/971/1*ueKMpsl9j3wvWNIUlc5AzA.png" /></figure><p>Typically a white or green candle represents the close price above the open price and a black or red candle represents the close price below the open price. So,</p><ol><li>Each candlesticks displays high, low, open and close.</li><li>The color indicates bullish (rising prices) or bearish (falling prices) movement.</li></ol><p><strong>Plot Candlestick chart with Python</strong></p><p><strong>W</strong>e can easily plot candlestick charts using the python package,</p><p>plotly.graph_objects as go <br>we import the package as go and then we define a candlestick using the time series dataindex, ie Date and the “Open”, “High”, “Low”, “Close” columns in the price data.</p><p>we then call figure to create a plot passing in our data as a list.</p><p>finally we call the show method to display it, this will create an interactive chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TS-8SRfCLWSEpVDTx0mAKA.png" /></figure><p>In the next episode, we will go through familiarity with the trading data, resampling, plotting a return histogram, financial trading with bt and many more using python.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d3c5833e0b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P6-SQL-Aggregation- Population Density Difference]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p6-sql-aggregation-population-density-difference-304e2e09301e?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/304e2e09301e</guid>
            <category><![CDATA[hackerrank-sql]]></category>
            <category><![CDATA[hackerrank]]></category>
            <category><![CDATA[hackerrank-solution]]></category>
            <category><![CDATA[hackerrank-solutions-sql]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 13:31:27 GMT</pubDate>
            <atom:updated>2024-08-12T13:31:27.312Z</atom:updated>
            <content:encoded><![CDATA[<p>Question is</p><p>Query the difference between the maximum and minimum populations in <strong>CITY</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*kh380NJsKBIaawn-wdQzdQ.png" /></figure><p>Select max(population) — min(population) as difference from city</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=304e2e09301e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P5-SQL-Aggregation- Japan Population]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p5-sql-aggregation-japan-population-5b6b51e391ed?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b6b51e391ed</guid>
            <category><![CDATA[hackerrank-solutions-sql]]></category>
            <category><![CDATA[hackerrank-sql]]></category>
            <category><![CDATA[hackerrank]]></category>
            <category><![CDATA[hackerrank-solution]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 13:26:57 GMT</pubDate>
            <atom:updated>2024-08-12T13:26:57.207Z</atom:updated>
            <content:encoded><![CDATA[<p>Question is</p><p>Query the sum of the populations for all Japanese cities in <strong>CITY</strong>. The COUNTRYCODE for Japan is <strong>JPN</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*-Eau_zC-t4ityoyN_n0w9w.png" /></figure><p>Solution is</p><p>select sum(population) from city where countrycode=’JPN’</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b6b51e391ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P4-(SQL-AggregationAverage Population)]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p4-sql-aggregationaverage-population-20ba12f0ae89?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/20ba12f0ae89</guid>
            <category><![CDATA[hackerrank-sql]]></category>
            <category><![CDATA[hackerrank-solutions-sql]]></category>
            <category><![CDATA[hackerrank-solution]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 13:23:24 GMT</pubDate>
            <atom:updated>2024-08-12T13:23:24.290Z</atom:updated>
            <content:encoded><![CDATA[<p>question is</p><p>Query the average population for all cities in <strong>CITY</strong>, rounded down to the nearest integer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*W8AD4SeulkAY8YX06AmjYQ.png" /></figure><p>Solution is</p><p>Select round(avg(population)) from city</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20ba12f0ae89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P3-(SQL- Aggregation — Aggregation Revising Aggregations — The Sum Function)]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p3-sql-aggregation-aggregation-revising-aggregations-the-sum-function-0700028dd5c7?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/0700028dd5c7</guid>
            <category><![CDATA[hackerrank-sql]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[hackerrank-solutions-sql]]></category>
            <category><![CDATA[hackerrank-solution]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 13:18:11 GMT</pubDate>
            <atom:updated>2024-08-12T13:18:11.320Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL HACKERANK SERIES-P3-(<a href="https://www.hackerrank.com/domains/sql">SQL</a>- Aggregation — Aggregation Revising Aggregations — The Sum Function)</h3><p>Question is</p><p>Query the average population of all cities in <strong>CITY</strong> where District is <strong>California</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*8YHJALLgvxh6IYI9-h_coA.png" /></figure><p>Solution is</p><p>select avg(population) from city where district= ‘California’</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0700028dd5c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P2-(SQL- Aggregation — Aggregation Revising Aggregations — The Sum Function)]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p2-sql-aggregation-aggregation-revising-aggregations-the-sum-function-5a3b7215c96f?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a3b7215c96f</guid>
            <category><![CDATA[hackerrank-sql]]></category>
            <category><![CDATA[hackerrank-solutions-sql]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Sat, 10 Aug 2024 13:24:43 GMT</pubDate>
            <atom:updated>2024-08-10T13:24:43.991Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL HACKERANK SERIES-P2-(<a href="https://www.hackerrank.com/domains/sql">SQL</a>- Aggregation — Aggregation Revising Aggregations — The Sum Function)</h3><p>Question is</p><p>Query the total population of all cities in <strong>CITY</strong> where District is <strong>California</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*G6illcOnc-vuR50dxuPsRg.png" /></figure><p>solution is</p><p>select sum(population) from city where district = ‘California’</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a3b7215c96f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P1-(SQL- Aggregation - Revising Aggregations — The Count Function)]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p1-sql-aggregation-revising-aggregations-the-count-function-e0af617778e1?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0af617778e1</guid>
            <category><![CDATA[hackerrank-solutions-sql]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Sat, 10 Aug 2024 13:20:42 GMT</pubDate>
            <atom:updated>2024-08-10T13:20:42.747Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL HACKERANK SERIES-P1-(<a href="https://www.hackerrank.com/domains/sql">SQL</a>- Aggregation - Revising Aggregations — The Count Function)</h3><p>Question is</p><p>Query a count of the number of cities in <strong>CITY</strong> having a Population larger than 100,000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*SdS2mjL-Pe9tF3dGgJHOaw.png" /></figure><p>Solution is</p><p>select count(name) from city where population &gt; 100000</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0af617778e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python for data analysis (for beginners) Day-5]]></title>
            <link>https://medium.com/@acanshi277/python-for-data-analysis-for-beginners-day-5-5905c05e1e2c?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5905c05e1e2c</guid>
            <category><![CDATA[data-analytics-courses]]></category>
            <category><![CDATA[datascience-python-course]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Sat, 10 Aug 2024 13:00:44 GMT</pubDate>
            <atom:updated>2024-08-10T13:00:44.291Z</atom:updated>
            <content:encoded><![CDATA[<p>We have learned in the previous episode how to make line plots using matplotlib module. In this episode, we will learn about several additional plot types, starting with scatter plots.</p><p>A scatter plot allows us to show where each data point sits on a grid. Line plots let us visualize ordered data points, but scatter plots are a great way of viewing un-ordered points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*7YZ035hD3jNLqa1jG7kamw.png" /></figure><p>For example, we want to learn about how a dog grows during their first year of life.</p><p>In python, we create scatter plot using plt.scatter(a,b) function.</p><p>first argument is x data in this example this is the age of a puppy</p><p>second argument is y data in this example this is the height of the puppy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*PGk0dxRgAwJ54Tztm_o2Gw.png" /></figure><p>we can then add labels and use plt.show just as we would for a line plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*Tpaf7oHbMnQeeLzSmt2MYQ.png" /></figure><p>Many of the same keyword arguments that we used in line plots will work in scatter plots. let’s use color and marker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*LchsBpj71NqsWzF8D6oCtg.png" /></figure><p>The keyword marker to change the marker shapes to squares and color to change the marker color to green.</p><p>Changing marker transparency</p><p>If we try to plot many points on the same scatter plot, things can get chaotic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*lGsszta6JkaC2uQNa2pQXg.png" /></figure><p>We can’t see if we have plotted many layers of points or just a single layer. We can make it easier to read by using a new keyword : alpha.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*eDglgsuMxVxNP2OQhoCvqA.png" /></figure><p>Alpha accepts a number between 0 and 1 and makes each marker transparent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*GYnvEq-gu6y2T3I6blzR5Q.png" /></figure><p>The smaller the alpha parameter, the more transparent the dot. Now we know that the darker areas have many points, while the lighter areas have fewer points.</p><p>Now, let’s learn about another chart that is Bar Chart.</p><p>The best way to visualize a comparison of categorical data is by using a bar chart. It’s simple to create a bar chart, we simply provide two arguments to function plt.bar(labels for each bar, height of each bar) because the x-axis is labeled for us, we only need to add a label for the y-axis using plt.ylabel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*wuvdNaYlMyWToaITf2xmTw.png" /></figure><p>We can also make a horizontal bar chart. We simple use the function plt.barh instead of plt.bar, when we have many bars, it can be easier to fit all of the labels in with a horizontal bar plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5grAOvzy_F8kx3SxOKxLDw.png" /></figure><p>Adding error bars</p><p>Averages don’t always tell the full story, often we will want to show some sort of error associates with our average such as the standard deviation or standard error of the mean.</p><p>plt.bar(df.x,df.y, yerr=df.error )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*LRfFgMQB4CscwG0BWcr3og.png" /></figure><p>in this case, we are filling yerr with a column of our dataframe called error.</p><p>Stacked Bar charts</p><p>In a stacked bar chart we display two different sets of bars the height of each colored bar represents one item and the height of total bar is total item.</p><p>For example below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BZ84GNAR-KAoVXeZjADVg.png" /></figure><p>To create this stacked bar chart, we start by plotting column as we normally would</p><p>plt.bar(df.column1, df.column2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*8vt1A8k0kWYzjLJXGIZWoQ.png" /></figure><p>y=0 and x=4</p><p>Next, we stack the cat bars on the top of the dog bars by using the keyword bottom. Normally, a bar chart will start each bar at 0, but if we add the keyword “bottom” to plt.bar and feed in the heights of our bottom bars (in this case df.dog)</p><p>Matplotlib will plot the second set of bars starting where the first set of bars ends.</p><p>For this particular bar, the cat starts at a height of y equals 4 and ends at a height of y equals 10.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*yn9J15Ta-7Ga_JbYbPi8XA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0godCHRuJxSReqf1Y9h5kg.png" /></figure><p>Let’s move to the last plot of this episode i.e the histograms</p><p>Histograms</p><p>The best way to visualize the distribution of data points is by creating a histograms. A histogram visualizes the distribution of values in a dataset.</p><p>To create a histogram, we place each piece of data into a bin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*0KNHueVqm0mJ4LZLOWIT0g.png" /></figure><p>In this example, we have divided our data into four bins: 1–10 , 11–20, 21–30 and 31–40 mm.</p><p>The histogram tells us how many piece of data fall into each of those bins. When we look at a histogram, we can quickly understand the entire dataset. Plotting a histogram in matplotlib is easy. We simply usie the command the plt.hist(), this function takes just one positional argument our dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aP0DYImzJK59VrBAtv7xCQ.png" /></figure><p>By default matplotlib will create a histogram with 10 bins of equal size spanning from the smallest sample to the largest sample in our dataset.</p><p>If we want to change the number of bins we can use the keyword argument ‘bins’ , bins accepts one integer. let’s change the number of bins, we divide our histogram into 40 bins. This allows us to see more detail in our histogram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fZpzRHMYCw7akijvadQiaw.png" /></figure><p>If we want to zoom in on a specific piece of our dataset, we can use the keyword ‘range’ to set the minimum and maximum value for our histogram. Note that we give the minimum and maximum values inside of a second set of parenthesis separated by a comma. Let’s use 50 minimum and 100 maximum to see how it works,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HESTaR7k3Z2gwVIzMSCR0g.png" /></figure><p>Suppose we wanted to compare the distributions of weights of different category of data example male and female puppies. For some reason, we were able to collect many more samples of male puppy weights than female puppy weights. When we plot both histograms on the same axes, we can’t actually see the difference in the distributions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*UEt9PIFNXILdkLHN8VIF7Q.png" /></figure><p>When we plot both histograms on the same axes, we can’t actually see the difference in the distributions, in this case, we don’t actually care about the absolute number of male puppies with a given weight, instead we care about what proportion of the dataset has that weight, we can solve this problem with normalization. Normalization reduces the height of each bar by a constant factor so that the sum of the areas of each bar adds to one. This would make our two histograms comparable, even if the sample sizes are different. We can normalize our histogram by using the keyword argument density equals True. Now each bar represents a proportion of the entire dataset. If a bar from the male puppies has the same height as a bar from the female puppies, both bars represent the same proportion of each population.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*65vIC6L4s59CCa_g6t62Iw.png" /></figure><p>Let’s discuss what we have learned in this series</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*4LBIGH1u6CgR2Aq3KtX5FQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*mLrArDYQMXPagiEJ3LaoUQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ogOURMLJPfb6-89E7Pk2A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gCn8wgPoSrQdQHZZYm_o7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGSHuqrYozqxymoYYt_LPw.png" /></figure><p>I hope this series helped in learning the python in regards with analysis and data science.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5905c05e1e2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL HACKERANK SERIES-P1-(SQL- Advanced Select-Type of Triangle)]]></title>
            <link>https://medium.com/@acanshi277/sql-hackerank-series-p1-sql-advanced-select-type-of-triangle-92b3a1ba1a15?source=rss-de5360c1895c------2</link>
            <guid isPermaLink="false">https://medium.com/p/92b3a1ba1a15</guid>
            <category><![CDATA[hackerrank]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Anshi Choudhary]]></dc:creator>
            <pubDate>Fri, 09 Aug 2024 13:09:55 GMT</pubDate>
            <atom:updated>2024-08-09T13:09:55.889Z</atom:updated>
            <content:encoded><![CDATA[<p>Question is</p><p>Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:</p><p>Equilateral: It’s a triangle with 3 sides of equal length.<br>Isosceles: It’s a triangle with 2 sides of equal length.<br>Scalene: It’s a triangle with 3 sides of differing lengths.<br>Not A Triangle: The given values of A, B, and C don’t form a triangle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*l59OImL1CR8tD1KrBqVUiA.png" /></figure><p>Sample input is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*gy26jsVUdww-DZrEfwFb0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*U2IWo3nIM-FikKrxo5uTUQ.png" /></figure><p>Solution is</p><p>select <br>case<br>when a+b&lt;=c then ‘Not A Triangle’<br>when a!=b and b!=c and c!=a then ‘Scalene’<br>when a=b and b=c and c=a then ‘Equilateral’<br>else ‘Isosceles’<br>end as ‘Triangle’<br>from triangles;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92b3a1ba1a15" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>