<?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: Beryl Chebet</title>
    <description>The latest articles on DEV Community by Beryl Chebet (@beryltoo).</description>
    <link>https://dev.to/beryltoo</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%2F749974%2F8a88d791-7364-4a3d-ad51-6cc2946d635e.png</url>
      <title>DEV Community: Beryl Chebet</title>
      <link>https://dev.to/beryltoo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/beryltoo"/>
    <language>en</language>
    <item>
      <title>Pandas map()function with example</title>
      <dc:creator>Beryl Chebet</dc:creator>
      <pubDate>Thu, 07 Apr 2022 21:11:19 +0000</pubDate>
      <link>https://dev.to/beryltoo/pandas-mapfunction-with-example-48pm</link>
      <guid>https://dev.to/beryltoo/pandas-mapfunction-with-example-48pm</guid>
      <description>&lt;p&gt;Map() function allows us to transform data in a DataFrame or series one value at a time.A dataframe is a table with a value corresponding to a row and column entry.An example of creating a dataframe is as shown:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DataFrame&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'Age'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;27&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;28&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="s"&gt;'Gender'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="s"&gt;'Female'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Male'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Female'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Male'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Male'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Male'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Female'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="s"&gt;'Marks'&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="mi"&gt;66&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;90&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;95&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;88&lt;/span&gt;&lt;span class="p"&gt;]})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should look like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DEOKVNzO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4if6jjfjo75v0l73kjjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DEOKVNzO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4if6jjfjo75v0l73kjjd.png" alt="table DataFrame" width="268" height="295"&gt;&lt;/a&gt;&lt;br&gt;
In the above example we created a DataFrame &lt;em&gt;table&lt;/em&gt; using &lt;em&gt;pd.DataFrame()&lt;/em&gt; having the columns age,gender,marks.Entries are assigned to the respective columns as shown in the square brackets.&lt;br&gt;
Now lets jump into using the map()function&lt;/p&gt;

&lt;h2&gt;
  
  
  Mapping female with 1 and male with 0 then displaying result on a different column.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'sex_num'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Gender&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'Female'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Male'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[:,[&lt;/span&gt;&lt;span class="s"&gt;'Gender'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'sex_num'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;table['sex_num']&lt;/em&gt; creates a new column sex_num,Gender.map specifies the values to map with in the column Gender. &lt;em&gt;Dataframe.loc&lt;/em&gt; is used for accessing multiple columns . In this case we want to access the columns &lt;em&gt;'Gender'&lt;/em&gt; and 'sex_num'. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M7Q4bdGP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vavt6ap00sum13vxh9g5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M7Q4bdGP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vavt6ap00sum13vxh9g5.png" alt="Comparison of Gender and sex num" width="212" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  To find deviation from mean mark
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;dev_mean&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Marks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'Deviation_From_Mean'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Marks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;dev_mean&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loc&lt;/span&gt;&lt;span class="p"&gt;[:,[&lt;/span&gt;&lt;span class="s"&gt;'Deviation_From_Mean'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'Marks'&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;table.Marks.mean()&lt;/em&gt; tells pandas to calculate the marks mean and assign it to &lt;em&gt;dev_mean.&lt;/em&gt; &lt;em&gt;table['Deviation_From_Mean']_creates a new column deviation from mean and  maps a lambda function _lambda p:p-dev_mean&lt;/em&gt; to each value of the column.A lambda function can take a number of arguments &amp;amp; execute an expression. The lambda function has a keyword, a variable and an expression.The keyword is lambda &amp;amp; must be included whenever you're using lambda function. In &lt;em&gt;lambda p:p-dev_mean&lt;/em&gt; &lt;em&gt;p _stands for each of the entries in the marks column. The expression _p-dev_mean&lt;/em&gt; subtracts  the dev_mean from each of the entries.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--suUMcWen--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7w4ko5w5095d61x6c71.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--suUMcWen--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7w4ko5w5095d61x6c71.png" alt="Output" width="302" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>pandas</category>
      <category>datascience</category>
      <category>python</category>
    </item>
    <item>
      <title>Creating an SQLite Database From Excel Workbook.</title>
      <dc:creator>Beryl Chebet</dc:creator>
      <pubDate>Mon, 28 Mar 2022 20:49:27 +0000</pubDate>
      <link>https://dev.to/beryltoo/creating-an-sqlite-database-from-excel-workbook-2opi</link>
      <guid>https://dev.to/beryltoo/creating-an-sqlite-database-from-excel-workbook-2opi</guid>
      <description>&lt;p&gt;A database is an organized collection of rows and columns with data that are related to each other. Sometimes you have an excel worksheet and would like to query it using SQL. This post  takes you through using Pandas to create an SQLite database from an excel sheet. So let's jump into it .&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1:Load the dataset to Pandas
&lt;/h2&gt;

&lt;p&gt;To load the dataset from excel to pandas use the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ```python 
      import pandas as pd 
      import sqlite3
      df=pd.read_excel('path to file')```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Import pandas as pd&lt;/em&gt; tells python to bring the pandas data analysis library into your current environment. &lt;em&gt;pd&lt;/em&gt; portion of the code tells python to give pandas the alias pd. This means you can use pandas by typing pd. &lt;em&gt;Import sqlite3&lt;/em&gt; provides an SQL-like interface to read,query and write SQL databases from python.&lt;em&gt;df=pd.read_excel('path to file')&lt;/em&gt; tells pandas to read the excel document in a specific location.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create SQLite database using sqlite3.connect()
&lt;/h2&gt;

&lt;p&gt;The following sample code creates an empty database file called &lt;em&gt;Day.db&lt;/em&gt; and assigns it to a variable &lt;em&gt;db_conn&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   ```db_conn=sqlite3.connect('Day.db')```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides an interface for working with the SQLite database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3:Create a cursor object to run the SQL code that will create the data tables.
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Cursor&lt;/em&gt; is an instance using which you can invoke methods that execute SQLite statements from the result sets of the queries i.e makes the connection for executing SQL queries on the SQLite database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```cur=db_conn.cursor()```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4:Create a table
&lt;/h2&gt;

&lt;p&gt;This is a command used to create a table called DayofWeeek with new columns Day and Sum.The data type for each column is specified to the right of the column name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```create_table="CREATE TABLE DayofWeek(Day TEXT,Sum INT)```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The column names must match those stored in the dataframe.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6:Moving from pandas dataframe to SQL table
&lt;/h2&gt;

&lt;p&gt;.to_sql command is used to write records stored in a dataframe to a SQL database.&lt;em&gt;DayofWeek&lt;/em&gt; specifies the the name of SQL table created.&lt;br&gt;
&lt;em&gt;if_exists='append'&lt;/em&gt; inserts new values into the existing table DayofWeek.&lt;em&gt;index=False&lt;/em&gt; to avoid bringing the dataframe index as a column.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;```df.to_sql('DayofWeek',db_conn,if_exists='append', index=False)```
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run your sql commands on pandas for example:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
pd.read_sql("SELECT * FROM DayofWeek",db_conn)


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

&lt;/div&gt;

</description>
      <category>database</category>
      <category>beginners</category>
      <category>dataanalytics</category>
      <category>pandas</category>
    </item>
    <item>
      <title>What is data analytics? Types , careers and importance.</title>
      <dc:creator>Beryl Chebet</dc:creator>
      <pubDate>Tue, 15 Feb 2022 15:12:39 +0000</pubDate>
      <link>https://dev.to/beryltoo/what-is-data-analytics-types-careers-and-importance-26hm</link>
      <guid>https://dev.to/beryltoo/what-is-data-analytics-types-careers-and-importance-26hm</guid>
      <description>&lt;p&gt;Data analytics is the process of cleaning data to get information. it involves collecting and transferring valuable information from useless data and analyzing it to generate numerical data and patterns that can lead to profitable improvement. Therefore, a data analyst is someone who gets information from raw data and can use the information to determine trends, provide solutions and describe problems and their possible solutions. &lt;br&gt;
Data analytics is important in&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Supporting decision making – To deliver critical insights on whether a business is moving in the right direction, data analytics in business is effective in determining market trends and explaining the key drivers of the success of a product or service versus another which may not be faring as well.&lt;/li&gt;
&lt;li&gt; Driving productivity, efficiency, and revenue growth- The results from analyzing data sets is going to tell an organization where they can optimize, which processes can be optimized or automated, which processes they can get better efficiencies out of and which processes are unproductive and thus can have resources dedicated away.&lt;/li&gt;
&lt;li&gt; Determining more effective marketing strategies- Businesses can use data analytics to better understand their client base in terms of customer trends and behaviors. This information can be used focus on more effective pitching of products and services.
The different types of data analysis are Predictive analysis, prescriptive analysis, descriptive analysis and diagnostic analysis.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;•Descriptive analysis: describes what happened based on past events. &lt;br&gt;
•Diagnostic analysis: aims to understand what happened and why it happened,&lt;br&gt;
•Predictive analysis: forecasting on what will happen in the future.&lt;br&gt;
•Prescriptive analysis: states what action should be done to achieve a goal.&lt;/p&gt;

&lt;p&gt;Various roles that require knowledge of data analytics, some of these roles are business intelligence analyst, data analyst, data scientist, data engineer, quantitative analyst and marketing analyst. Data analysis is providing skills that are very important to various fields, some of these fields are healthcare, cybersecurity, businesses and marketing. Transportation. These are just but a few fields where data analytics is applied, data analytics does not limit you to a particular field. With a relevant set of technical skills, you can grow into any field of interest.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>database</category>
      <category>career</category>
    </item>
  </channel>
</rss>
