<?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"><channel><title><![CDATA[Journey into Pandas]]></title><description><![CDATA[Journey into Pandas]]></description><link>https://pandasli.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 07:31:28 GMT</lastBuildDate><atom:link href="https://pandasli.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[🚀 A Beginner’s Journey into Pandas]]></title><description><![CDATA[Understanding Series, DataFrames, and Key Methods
Pandas is one of the most powerful and easy-to-use Python libraries for data analysis.
In this post, we’ll walk through how pandas works - from creating Series & DataFrame to analyzing data

Pandas is...]]></description><link>https://pandasli.hashnode.dev/a-beginners-journey-into-pandas</link><guid isPermaLink="true">https://pandasli.hashnode.dev/a-beginners-journey-into-pandas</guid><category><![CDATA[Python]]></category><category><![CDATA[pandas]]></category><dc:creator><![CDATA[M Krunal]]></dc:creator><pubDate>Sun, 19 Oct 2025 17:45:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1760894289029/13044433-bfbe-4ee9-ad40-dc409f52778a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-understanding-series-dataframes-and-key-methods">Understanding Series, DataFrames, and Key Methods</h1>
<p>Pandas is one of the most powerful and easy-to-use Python libraries for data analysis.</p>
<p>In this post, we’ll walk through how pandas works - from creating Series &amp; DataFrame to analyzing data</p>
<hr />
<p>Pandas is a popular Python library used for data analysis and manipulation. It provides two main data structures:</p>
<ol>
<li><p>Series → One-dimensional labeled array (like a column in Excel)</p>
</li>
<li><p>DataFrame → Two-dimensional labeled data (like an Excel sheet)</p>
</li>
</ol>
<h2 id="heading-step-1-creating-a-series">🧩 Step 1: Creating a Series</h2>
<p>A <strong>Series</strong> in pandas is like a one-dimensional array (similar to a list), but with labels (<strong>index</strong>) attached to each value.</p>
<pre><code class="lang-plaintext">import pandas as pd

series1 = pd.Series(data = [10, 20, 30, 40, 50], index=['a', 'b', 'c', 'd', 'e'])
print(series1)
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">a    10
b    20
c    30
d    40
e    50
dtype: int64
</code></pre>
<p><strong>Explanation:</strong></p>
<ul>
<li><p>The <strong>values</strong> are <code>[10, 20, 30, 40, 50]</code></p>
</li>
<li><p>The <strong>index labels</strong> are <code>['a', 'b', 'c', 'd', 'e']</code></p>
</li>
<li><p>First list by default considered as data list, its optional to write <code>data</code></p>
</li>
</ul>
<p>If you remove the <code>index</code> argument, pandas automatically assigns default index numbers starting from <code>0</code>.</p>
<pre><code class="lang-plaintext">series1 = pd.Series([10, 20, 30, 40, 50])
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">0    10
1    20
2    30
3    40
4    50
</code></pre>
<p>💡 <em>Tip:</em> If you remove only the keyword <code>index=</code> but still pass the index list, it will still work fine because pandas detects the position of arguments automatically</p>
<hr />
<h2 id="heading-step-2-creating-series-from-a-dictionary">🚗 Step 2: Creating Series from a Dictionary</h2>
<p>You can also create a Series directly from a Python dictionary.</p>
<pre><code class="lang-plaintext">entries = { 
  'swift': 649000,
  'santro': 391000,
  'audi': 5476000,
  'elantra': 1786000,
  'bolero': 1091000
}

car_series1 = pd.Series(data=entries)
</code></pre>
<p>Alternatively, you can use separate lists for <strong>values</strong> and <strong>index</strong>:</p>
<pre><code class="lang-plaintext">prices = [649000, 391000, 5476000, 1786000, 1091000]
carnames = ['swift', 'santro', 'audi', 'elantra', 'bolero']

car_series2 = pd.Series(data=prices, index=carnames)
</code></pre>
<p>✅ Both <code>car_series1</code> and <code>car_series2</code> will work the same and produce identical output because the data and indices match.</p>
<p>🌟Aap check bhi kar sakte ho: <code>print(car_series1.equals(car_series2))</code></p>
<hr />
<h2 id="heading-step-3-accessing-data-loc-vs-iloc">🎯 Step 3: Accessing Data – <code>.loc[]</code> vs <code>.iloc[]</code></h2>
<p>To access elements in a Series, pandas provides two powerful methods:</p>
<h3 id="heading-loc-label-based-indexing"><code>.loc[]</code> → <strong>Label-based indexing</strong></h3>
<p>Use the <strong>index name</strong>.</p>
<pre><code class="lang-plaintext">car_series1.loc['audi']
</code></pre>
<p>Output:</p>
<pre><code class="lang-plaintext">5476000
</code></pre>
<h3 id="heading-iloc-integer-position-based-indexing"><code>.iloc[]</code> → <strong>Integer position-based indexing</strong></h3>
<p>Use the <strong>index position (number)</strong>.</p>
<pre><code class="lang-plaintext">car_series1.iloc[2]
</code></pre>
<p>Output:</p>
<pre><code class="lang-plaintext">5476000
</code></pre>
<p>🪄 <strong>In short:</strong></p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Method</td><td>Access Type</td><td>Example</td></tr>
</thead>
<tbody>
<tr>
<td><code>.loc[]</code></td><td>By label</td><td><code>car_series.loc['audi']</code></td></tr>
<tr>
<td><code>.iloc[]</code></td><td>By position</td><td><code>car_series.iloc[2]</code></td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-step-4-whats-the-difference-between-carserieslocaudi-and-carseriesaudi">⚖️ Step 4: What’s the difference between <code>car_series.loc['audi']</code> and <code>car_series['audi']</code>?</h2>
<p>Both work the same for simple Series lookups — they return the value associated with the label <code>'audi'</code>.</p>
<p>However:</p>
<ul>
<li><p><code>.loc[]</code> is more <strong>explicit</strong> and is the preferred method when writing clear, maintainable code.</p>
</li>
<li><p>Direct indexing (<code>[]</code>) is a <strong>shortcut</strong> that works fine in most cases.</p>
</li>
</ul>
<p>🗣️ <em>Chhoti baat, par important hai!</em> → Use <code>.loc[]</code> when working on professional projects to avoid confusion later.</p>
<hr />
<h2 id="heading-step-5-boolean-filtering">🔍 Step 5: Boolean Filtering</h2>
<p>Boolean filtering allows you to <strong>select data based on conditions</strong>.</p>
<p>Example:</p>
<pre><code class="lang-plaintext">print(car_series1[car_series1 &gt; 1000000])
</code></pre>
<p><strong>Output:</strong></p>
<pre><code class="lang-plaintext">swift      649000
audi      5476000
elantra   1786000
bolero    1091000
dtype: int64
</code></pre>
<p>You can also combine multiple conditions:</p>
<pre><code class="lang-plaintext">car_series1[(car_series1 &gt; 1000000) &amp; (car_series1 &lt; 5000000)]
</code></pre>
<hr />
<h2 id="heading-step-6-reading-csv-files-in-pandas">📂 Step 6: Reading CSV Files in Pandas</h2>
<p>There are multiple ways to load a CSV file:</p>
<pre><code class="lang-plaintext">df = pd.read_csv("data.csv")               # Most common
df = pd.read_table("data.csv", sep=',')    # Alternate
df = pd.read_csv("data.csv", header=None)  # Without headers
df = pd.read_csv("data.csv", nrows=10)     # Read first 10 rows
</code></pre>
<p>💡 You can even load files from URLs:</p>
<pre><code class="lang-plaintext">df = pd.read_csv("https://example.com/data.csv")
</code></pre>
<hr />
<h2 id="heading-step-7-dataframe-exploration-methods">🧾 Step 7: DataFrame Exploration Methods</h2>
<p>Once your data is loaded, you can quickly inspect it using these handy tools:</p>
<h3 id="heading-info">🔹 <code>.info()</code></h3>
<p>Shows a <strong>summary of the DataFrame</strong> — structure, data types, and non-null counts.</p>
<pre><code class="lang-plaintext">df.info()
</code></pre>
<h3 id="heading-describe">🔹 <code>.describe()</code></h3>
<p>Gives <strong>statistical summaries</strong> of numeric columns.</p>
<pre><code class="lang-plaintext">df.describe()
</code></pre>
<p>To include all columns (even strings):</p>
<pre><code class="lang-plaintext">df.describe(include='all')
</code></pre>
<hr />
<h2 id="heading-step-8-shape-and-columns">🧮 Step 8: <code>.shape</code> and <code>.columns</code></h2>
<p>These attributes help you understand the <strong>structure</strong> of your dataset.</p>
<pre><code class="lang-plaintext">df.shape     # Returns (rows, columns)
df.columns   # Returns list of column names
</code></pre>
<p>Example:</p>
<pre><code class="lang-plaintext">print("Rows:", df.shape[0])
print("Columns:", df.shape[1])
</code></pre>
<p>Output:</p>
<pre><code class="lang-plaintext">Rows: 4
Columns: 3
</code></pre>
<p>Here:</p>
<ul>
<li><p><code>df.shape[0]</code> → gives number of rows</p>
</li>
<li><p><code>df.shape[1]</code> → gives number of columns</p>
</li>
</ul>
<p>📌 <em>Yaad rakho:</em> <code>.shape</code> and <code>.columns</code> are <strong>attributes</strong>, not methods — no parentheses <code>()</code> needed.</p>
<hr />
<h2 id="heading-final-thoughts">🏁 Final Thoughts</h2>
<p>By now, we’ve covered:</p>
<ul>
<li><p>Creating and accessing Series</p>
</li>
<li><p>Using <code>.loc[]</code> and <code>.iloc[]</code></p>
</li>
<li><p>Boolean filtering</p>
</li>
<li><p>Reading CSV files</p>
</li>
<li><p>Exploring DataFrames with <code>.info()</code>, <code>.describe()</code>, <code>.shape</code>, and <code>.columns</code></p>
</li>
</ul>
<p>💬 <em>Ek line mein kahun toh</em> — Pandas is not just a library; it’s a <strong>superpower</strong> for anyone who works with data.</p>
<p>Keep experimenting and practicing with real datasets — that’s how you’ll truly master it.</p>
<hr />
<h3 id="heading-written-by-krunal-r-mandlekar">✍️ Written by: <strong>Krunal R. Mandlekar</strong></h3>
<p>📧 krunalmandlekar@gmail.com<br />🔗 <a target="_blank" href="http://www.linkedin.com/in/krunal-mandlekar-397b11313">www.linkedin.com/in/krunal-mandlekar-397b11313</a></p>
]]></content:encoded></item></channel></rss>