Statement of Completion#9b318382
Intro to Pandas for Data Analysis
easy
DataFrames practice: working with English Words
Resolution
Activities
Project.ipynb
In [1]:
import pandas as pd
In [2]:
df = pd.read_csv('words.csv', index_col='Word')
In [3]:
df.head()
Out[3]:
Char Count | Value | |
---|---|---|
Word | ||
aa | 2 | 2 |
aah | 3 | 10 |
aahed | 5 | 19 |
aahing | 6 | 40 |
aahs | 4 | 29 |
Activities¶
How many elements does this dataframe have?¶
In [4]:
df.info()
<class 'pandas.core.frame.DataFrame'> Index: 172821 entries, aa to zyzzyvas Data columns (total 2 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Char Count 172821 non-null int64 1 Value 172821 non-null int64 dtypes: int64(2) memory usage: 4.0+ MB
What is the value of the word microspectrophotometries
?¶
In [8]:
df.loc['microspectrophotometries', 'Value']
Out[8]:
317
What is the highest possible value of a word?¶
In [9]:
df['Value'].max()
Out[9]:
319
Which of the following words have a Char Count of 15
?¶
In [17]:
df.loc[['glowing', 'superheterodyne', 'microbrew', 'pinfish', 'enfold']]
Out[17]:
Char Count | Value | |
---|---|---|
Word | ||
glowing | 7 | 87 |
superheterodyne | 15 | 198 |
microbrew | 9 | 106 |
pinfish | 7 | 81 |
enfold | 6 | 56 |
What is the highest possible length of a word?¶
In [19]:
df['Char Count'].max()
df.loc[df['Char Count'] == 28]
Out[19]:
Char Count | Value | |
---|---|---|
Word | ||
ethylenediaminetetraacetates | 28 | 287 |
What is the word with the value of 319
?¶
In [20]:
df.loc[df['Value'] == 319]
Out[20]:
Char Count | Value | |
---|---|---|
Word | ||
reinstitutionalizations | 23 | 319 |
What is the most common value?¶
In [26]:
common_values = df['Value'].value_counts()
What is the shortest word with value 274
?¶
In [28]:
two_seven_four = df.loc[df['Value'] == 274]
two_seven_four
Out[28]:
Char Count | Value | |
---|---|---|
Word | ||
countercountermeasure | 21 | 274 |
overprotectivenesses | 20 | 274 |
psychophysiologically | 21 | 274 |
Create a column Ratio
which represents the 'Value Ratio' of a word¶
In [33]:
df['Ratio'] = df['Value'] / df['Char Count']
df
del df["Ration"]
What is the maximum value of Ratio
?¶
In [36]:
df['Ratio'].max()
Out[36]:
22.5
What word is the one with the highest Ratio
?¶
In [37]:
df.loc[df['Ratio'] == df['Ratio'].max()]
Out[37]:
Char Count | Value | Ratio | |
---|---|---|---|
Word | |||
xu | 2 | 45 | 22.5 |
How many words have a Ratio
of 10
?¶
In [39]:
df.loc[df['Ratio'] == 10]
Out[39]:
Char Count | Value | Ratio | |
---|---|---|---|
Word | |||
aardwolf | 8 | 80 | 10.0 |
abatements | 10 | 100 | 10.0 |
abducts | 7 | 70 | 10.0 |
abetment | 8 | 80 | 10.0 |
abettals | 8 | 80 | 10.0 |
... | ... | ... | ... |
ycleped | 7 | 70 | 10.0 |
yodeled | 7 | 70 | 10.0 |
zamia | 5 | 50 | 10.0 |
zebecs | 6 | 60 | 10.0 |
zwieback | 8 | 80 | 10.0 |
2604 rows × 3 columns
What is the maximum Value
of all the words with a Ratio
of 10
?¶
In [42]:
df.loc[df['Ratio'] == 10].max()
Out[42]:
Char Count 24.0 Value 240.0 Ratio 10.0 dtype: float64
Of those words with a Value
of 260
, what is the lowest Char Count
found?¶
In [ ]:
two_seven_four = df.loc[df['Value'] == 260]
two_seven_four
Based on the previous task, what word is it?¶
In [ ]: