avatarJ3

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

1837

Abstract

id spotless.</p><p id="036a">My mum liked her home to be comfortable. She believed in clean, but ‘lived in.’ She wasn’t ever 100% tidy, she was <i>comfortably tidy. </i>Some days I would come home from school and every room in the house would be a little messy. However, if my mum had spent all day tidying up, she’d never have had a life.</p><p id="8f57">When my own children were young, my home was never ‘spotless’, and some professionals often complained that<b> I wasn’t tidy or clean enough.</b></p><p id="6e46">Bringing up six children was really hard, I did not have time to clean and tidy all day! Besides,</p><p id="3d1b" type="7">being too tidy and stressing yourself out over it in front of children teaches them that being messy is wrong!</p><p id="626e">If children grow up believing that cleaning is the only way to live, then they will grow up anxious about every little mess they make.</p><p id="a244" type="7">Parents should feel free to spend more time with their children because children need them more than housework needs them.</p><p id="04c5">My children are grown up today, but I still don’t do 100% tidy. I have laundry in my lounge to put away, and baskets of dirty clothes to wash, and everything is out of place,</p><p id="8f70"><b>But, I will clean it up in my own time.</b></p><p id="935a">We<i> </i>need to drop the concept of spotless because it causes people more stress than it is worth. Of course, we do need to clean and tidy our homes every now and then, in order to create a healthy home.</p><p id="9681">However, being too clean and tidy can be unhealthy; and in today’s world, do you really want to spend the rest of your life absorbed in chores?</p><p id="ac8b"><b>Life is for living, so please go away if you want spotless. You won’t get it at my house!</b></p><p id="a3e5">You might like to re

Options

ad the following:</p><div id="f87f" class="link-block"> <a href="https://readmedium.com/a-memory-never-forgotten-d92b5dfb2afa"> <div> <div> <h2>A Memory Never Forgotten.</h2> <div><h3>Writing: In The Beginning</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*jGTV-_KNxfyyAbfq)"></div> </div> </div> </a> </div><div id="d4cf" class="link-block"> <a href="https://readmedium.com/swing-swing-swing-40ef21118106"> <div> <div> <h2>Swing! Swing! Swing!</h2> <div><h3>About a little boy who had an obsession with the swings, yet left some golden moments in my heart to treasure forever.</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*d_Y5f3Tn1IJuAAoN)"></div> </div> </div> </a> </div><div id="d68e" class="link-block"> <a href="https://readmedium.com/do-you-always-feel-like-a-packhorse-after-a-holiday-cbb1e481b853"> <div> <div> <h2>Do You Always Feel Like a Packhorse After a Holiday?</h2> <div><h3>I always end up with more bags than I went with!</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*8TtnVjKGWer24Tx4)"></div> </div> </div> </a> </div></article></body>

Pandas — Operations

Pandas Dataframe Examples: Column Operations — #PySeries#Episode 14

print(“Hello Pandas operations!”)

Preparing our Notebook:

import numpy as np
import pandas as pd

The DataFrame:

df = pd.DataFrame({'col1':[1,2,3,4],
'col2':[444,555,666,444],
'col3':[‘abc’,’def’,’ghi’,’xyz’]})
df.head()

Operations in a DataFrame

Finding Unique Values:

df['col2'].unique()
array([444, 555, 666])

Another form:

len(df['col2'].unique())
3

Yet other:

df['col2'].nunique()
3

Counting Values

df['col2'].value_counts()

Conditional Selections

df

Returning a DataFrame where ‘col1’ happen to be greater than two:

df[df['col1']>2]

Combining Conditional Selection

df[(df['col1']>2) & (df['col2']==444)]

Apply Method

One of the powerful method in our tool belt When using Pandas;

We can grab a column and call a built-in function of it:

df['col2].sum()
2109

But we can apply our custom function:

def times2(x):
    return x*2

We can broadcast our function for each element in that column:

df['col2'].apply(times2)

Let’s go ahead and apply it with lambda expression:

This is probably the most powerful feature in Pandas: The ability to apply our custom lambda expression!

df[‘col2’].apply(lambda x:x*2)

Removing Columns

df

If you want that too occurs in place, we going to have to specify ‘implace=True’

df.drop('col1', axis=1)

Returning The Columns Name & Index Attributes

Columns:

df.columns
Index(['col1', 'col2', 'col3'], dtype='object')

Index:

df.index
RangeIndex(start=0, stop=4, step=1)

Sorting & Ordering a DataFrame

Just pass in the column we want to sort by:

df
df.sort_values('col2')
df.sort_values(by='col2')

Booleans

df.isnull()

Pivot Tables

The pivot table takes simple column-wise data as input and groups the entries into a two-dimensional table that provides a **multidimensional summarization of the data**

As we build up the pivot table, I think it’s easiest to take it one step at a time. Add items and check each step to verify you are getting the results you expect. Don’t be afraid to play with the order and the variables to see what presentation makes the most sense for your needs.

data=pd.DataFrame({'A':['foo','foo','foo','bar','bar','bar'],
'B':['one','one','two','two','one', 'one'],
'C':['x','y','x','y','x','y'],
'D':[1,3,2,5,4,1]})
#data
df=pd.DataFrame(data)
df

Pivot method takes 3 values: values, index, and columns:

df.pivot_table(values='D', index=['A','B'], columns='C')

print(“Thanks everyone! See you in the Next Pandas Lecture o/”)

Colab File link:)

Credits & References:

Jose Portilla — Python for Data Science and Machine Learning Bootcamp — Learn how to use NumPy, Pandas, Seaborn , Matplotlib , Plotly , Scikit-Learn , Machine Learning, Tensorflow , and more!

Posts Related:

00Episode#PySeries — Python — Jupiter Notebook Quick Start with VSCode — How to Set your Win10 Environment to use Jupiter Notebook

01Episode#PySeries — Python — Python 4 Engineers — Exercises! An overview of the Opportunities Offered by Python in Engineering!

02Episode#PySeries — Python — Geogebra Plus Linear Programming- We’ll Create a Geogebra program to help us with our linear programming

03Episode#PySeries — Python — Python 4 Engineers — More Exercises! — Another Round to Make Sure that Python is Really Amazing!

04Episode#PySeries — Python — Linear Regressions — The Basics — How to Understand Linear Regression Once and For All!

05Episode#PySeries — Python — NumPy Init & Python Review — A Crash Python Review & Initialization at NumPy lib.

06Episode#PySeries — Python — NumPy Arrays & Jupyter Notebook — Arithmetic Operations, Indexing & Slicing, and Conditional Selection w/ np arrays.

07Episode#PySeries — Python — Pandas — Intro & Series — What it is? How to use it?

08Episode#PySeries — Python — Pandas DataFrames — The primary Pandas data structure! It is a dict-like container for Series objects

09Episode#PySeries — Python — Python 4 Engineers — Even More Exercises! — More Practicing Coding Questions in Python!

10Episode#PySeries — Python — Pandas — Hierarchical Index & Cross-section — Open your Colab notebook and here are the follow-up exercises!

11Episode#PySeries — Python — Pandas — Missing Data — Let’s Continue the Python Exercises — Filling & Dropping Missing Data

12Episode#PySeries — Python — Pandas — Group By — Grouping large amounts of data and compute operations on these groups

13Episode#PySeries — Python — Pandas — Merging, Joining & Concatenations — Facilities For Easily Combining Together Series or DataFrame

14Episode#PySeries — Python — Pandas — Pandas Dataframe Examples: Column Operations (this one)

15Episode#PySeries — Python — Python 4 Engineers — Keeping It In The Short-Term Memory — Test Yourself! Coding in Python, Again!

16Episode#PySeries — NumPy — NumPy Review, Again;) — Python Review Free Exercises

17Episode#PySeriesGenerators in Python — Python Review Free Hints

18Episode#PySeries — Pandas Review…Again;) — Python Review Free Exercise

19Episode#PySeriesMatlibPlot & Seaborn Python Libs — Reviewing theses Plotting & Statistics Packs

20Episode#PySeriesSeaborn Python Review — Reviewing theses Plotting & Statistics Packs

Pandas Dataframe
Pandas
Numpy
Python3
Data Science
Recommended from ReadMedium