<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: techieteko</title>
    <description>The latest articles on DEV Community by techieteko (@techieteko).</description>
    <link>https://dev.to/techieteko</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F588213%2Fdffdca9d-40b0-401a-9880-ab1e39bc5af4.jpeg</url>
      <title>DEV Community: techieteko</title>
      <link>https://dev.to/techieteko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/techieteko"/>
    <language>en</language>
    <item>
      <title>What I Learned Today: Cleaning, Aggregating, and Visualizing Data with Python 🐍</title>
      <dc:creator>techieteko</dc:creator>
      <pubDate>Mon, 09 Dec 2024 13:07:35 +0000</pubDate>
      <link>https://dev.to/techieteko/-what-i-learned-today-cleaning-aggregating-and-visualizing-data-with-python-5e3d</link>
      <guid>https://dev.to/techieteko/-what-i-learned-today-cleaning-aggregating-and-visualizing-data-with-python-5e3d</guid>
      <description>&lt;p&gt;Today, I took a deep dive into Python for data analysis and visualization, and I learned so much! From cleaning messy datasets to debugging errors and creating charts, it was a day of breakthroughs. Here’s a recap of my journey and insights that might help you too. 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Cleaning Data with Pandas
&lt;/h2&gt;

&lt;p&gt;When working with real-world datasets, data isn't always clean. I encountered a column with prices formatted like "$22,000.00". To calculate averages or run analytics, I needed these values as numbers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Here’s the solution:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Remove unwanted characters (like $ and ,) using regex.&lt;/li&gt;
&lt;li&gt;Convert the cleaned data into float for numeric operations.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Cleaning the 'Price' column
&lt;/span&gt;&lt;span class="n"&gt;car_sales&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;car_sales&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Price&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[\$,]&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;regex&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;astype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What Happens Here:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;replace(r'[\$,]', &lt;code&gt;'',regex=True)&lt;/code&gt;: Removes &lt;code&gt;$&lt;/code&gt; and &lt;code&gt;,&lt;/code&gt;`.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.astype(float)&lt;/code&gt;: Converts the cleaned values into numeric format.&lt;/li&gt;
&lt;li&gt;After this, I could easily perform numeric operations like calculating averages or sums.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Grouping and Aggregating with Pandas
&lt;/h2&gt;

&lt;p&gt;Once the data was clean, I wanted to calculate the average price of cars by color. Pandas &lt;code&gt;groupby &lt;/code&gt; method made this a breeze:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1depvennwott36imb911.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1depvennwott36imb911.png" alt="Image description calculate price " width="800" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foeh3aac8kw684i3b6grd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foeh3aac8kw684i3b6grd.png" alt="Image description: Group by Color and calculate the mean price" width="800" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Grouping by color revealed insights I couldn’t see before. For instance, black cars had the highest average price! 🚗💰&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Visualizing Data with Matplotlib
&lt;/h2&gt;

&lt;p&gt;Data is great, but a chart makes it even better! I used Matplotlib to create a bar chart showing the average price of cars by color:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtz3eeoi54p6eowav3wi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgtz3eeoi54p6eowav3wi.png" alt="Image description:a bar chart showing the average price of cars by color:" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result? A beautiful bar chart that communicates insights at a glance. 📊&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Debugging Common Errors 🛠️
No learning journey is complete without errors! Here’s the error I encountered:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ahyb4pnuqu4qn9mfvyl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ahyb4pnuqu4qn9mfvyl.png" alt="Image description typeError" width="800" height="67"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Why did this happen?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The Price column contained strings, not numbers. Pandas couldn’t calculate the mean.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How I Fixed It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Used regex to clean the column.&lt;/li&gt;
&lt;li&gt;Converted the cleaned values to &lt;code&gt;float&lt;/code&gt; using 
&lt;code&gt;.astype()&lt;/code&gt;.
This reminded me how important it is to inspect your data types using &lt;code&gt;df.info()&lt;/code&gt; or &lt;code&gt;df.dtypes&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Key Takeaways 🎓
&lt;/h2&gt;

&lt;p&gt;Here’s what I learned today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data cleaning is essential: You can’t analyze messy data effectively.&lt;/li&gt;
&lt;li&gt;Regex is powerful: Mastering it opens up endless possibilities for text manipulation.&lt;/li&gt;
&lt;li&gt;Grouping simplifies analysis: groupby is your best friend for aggregations.&lt;/li&gt;
&lt;li&gt;Visualizations matter: Charts communicate insights better than raw data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Thoughts 💭
&lt;/h2&gt;

&lt;p&gt;This journey reinforced the importance of persistence. Each error I encountered taught me something valuable. If you’re new to Python and data analysis, I hope this post helps you avoid some pitfalls and inspires you to keep learning.&lt;/p&gt;

&lt;p&gt;What about you? Have you faced similar challenges with messy data? What tools or tricks do you use to clean and analyze data? Let me know in the comments! Let’s learn together. ✨&lt;/p&gt;




&lt;p&gt;Thanks for reading! 🙌&lt;br&gt;
If you found this helpful, don’t forget to share it. 🚀&lt;/p&gt;

&lt;h1&gt;
  
  
  python #datascience #pandas #matplotlib #learningjourney
&lt;/h1&gt;

</description>
      <category>python</category>
      <category>pandas</category>
      <category>matplotlib</category>
      <category>learningjourney</category>
    </item>
    <item>
      <title>how can i select those files</title>
      <dc:creator>techieteko</dc:creator>
      <pubDate>Wed, 21 Apr 2021 22:15:30 +0000</pubDate>
      <link>https://dev.to/tek4/how-can-i-select-those-files-65i</link>
      <guid>https://dev.to/tek4/how-can-i-select-those-files-65i</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/67204051/how-can-i-select-those-files" rel="noopener noreferrer"&gt;
               how can i select those files
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Apr 21 '21&lt;/span&gt;
            &lt;span&gt;Comments: 3&lt;/span&gt;
            &lt;span&gt;Answers: 0&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/67204051/how-can-i-select-those-files" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          0
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;i try array_map but did not work ;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write the code of the &lt;code&gt;goodExtension&lt;/code&gt; function which receives as argument the &lt;code&gt;$files&lt;/code&gt; parameter the function must return an indexed array without a key this array must contain only file names with the extension &lt;code&gt;.PHP&lt;/code&gt; and &lt;code&gt;.JS&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre&gt;&lt;code&gt;function goodExtention(Array $files){
}

$files&lt;/code&gt;&lt;/pre&gt;…
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/67204051/how-can-i-select-those-files" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
  </channel>
</rss>
