Docsity

Advanced Data Management Exercises: Pandas Fundamentals, Exams of Network security

Toggle sidebar
bg1
Final Advanced Data Management
T/F: The index of a Series object should be an integer ✔✔False
T/F: The Index object follows many of the conventions used by Python's built-in set data structure
✔✔True
T/F: Unlike a dictionary, the Series supports array-style operations such as slicing ✔✔True
T/F: A Pandas Series is a one-dimensional array of indexed data ✔✔True
indA = pd.Index([1, 3, 5, 7, 9])
indB = pd.Index([2, 3, 5, 7, 11])
indA | indB # union
- Int64Index([1, 2, 9, 11], dtype='int64')
- Int64Index([3, 6, 10, 14, 20], dtype='int64')
- Int64Index([3, 5, 7], dtype='int64')
- Int64Index([1, 2, 3, 5, 7, 9, 11], dtype='int64') ✔✔Int64Index([1, 2, 3, 5, 7, 9, 11], dtype='int64')
data = pd.Series([0.25, 0.5, 0.75, 1.0], index=['a', 'b', 'c', 'd'])
data[0:2] ✔✔a 0.25
b 0.50
dtype: float64
consider the DataFrame data
columns = area, pop
rows = California, Florida, Illinois, New York, Texas
to get the population of California
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Advanced Data Management Exercises: Pandas Fundamentals and more Exams Network security in PDF only on Docsity!

Final Advanced Data Management

T/F: The index of a Series object should be an integer ✔✔False

T/F: The Index object follows many of the conventions used by Python's built-in set data structure ✔✔True

T/F: Unlike a dictionary, the Series supports array-style operations such as slicing ✔✔True

T/F: A Pandas Series is a one-dimensional array of indexed data ✔✔True

indA = pd.Index([1, 3, 5, 7, 9])

indB = pd.Index([2, 3, 5, 7, 11])

indA | indB # union

  • Int64Index([1, 2, 9, 11], dtype='int64')
  • Int64Index([3, 6, 10, 14, 20], dtype='int64')
  • Int64Index([3, 5, 7], dtype='int64')
  • Int64Index([1, 2, 3, 5, 7, 9, 11], dtype='int64') ✔✔Int64Index([1, 2, 3, 5, 7, 9, 11], dtype='int64')

data = pd.Series([0.25, 0.5, 0.75, 1.0], index=['a', 'b', 'c', 'd'])

data[0:2] ✔✔a 0.

b 0.

dtype: float

consider the DataFrame data

columns = area, pop

rows = California, Florida, Illinois, New York, Texas

to get the population of California

  • data.pop['California']
  • data['California'].pop
  • data['pop'].loc['California']
  • data.loc['pop']['California'] ✔✔data['pop'].loc['California']

consider the DataFrame data

columns = area, pop

rows = California, Florida, Illinois, New York, Texas

  • data.Texas.area
  • data.iloc[-1,0]
  • data.iloc[0,-1]
  • data.iloc['area', 'Texas'] ✔✔- data.iloc[-1,0]

data = pd.Series(['a', 'b', 'c'], index=[1, 3, 5])

data.iloc[1]

  • 'b'
  • 'c'
  • 'a'
  • error ✔✔'b'

T/F: Like a dictionary, the Series object provides a mapping from a collection of keys to a collection of values ✔✔True

A = pd.Series([2, 4, 6], index=[0, 1, 2])

B = pd.Series([1, 3, 5], index=[1, 2, 3])

A + B

  • data.replacena(0)
  • data.fillna(0)
  • data.nan = 0
  • data = 0 ✔✔data.fillna(0)

What function can be used to fill each na value using the previous value in the data frame

  • data.forwardfill()
  • data.fillna(method='bfill')
  • data.fillna(method='ffill')
  • data.fillna(method='previous') ✔✔data.fillna(method='ffill')

Which function is used to return a copy of the data with missing values filled or imputed

  • fillna()
  • notnull()
  • isnull()
  • dropna() ✔✔fillna()

What are the two special sentinels that can be used to indicate a missing value?

  • NaN and Nill
  • None and NaN
  • None and False
  • null and nill ✔✔None and NaN

T/F: A multi-index can be used to represent two-dimensional data within a one-dimensional Series ✔✔True

T/F: A multi-indexed Series can be converted to a DataFrame ✔✔True

T/F: Pandas allows MultiIndex for columns ✔✔True

T/F: a MultiIndex can be used to represent data of more than two dimensions in a Series ✔✔True

What method can be used to convert a multiply indexed Series into a conventionally indexed DataFrame:

  • unstack()
  • unpack()
  • stack()
  • pack() ✔✔unstack()

ser1 = pd.Series(['A', 'B', 'C'], index=[1, 2, 3])

ser2 = pd.Series(['D', 'E', 'F'], index=[1, 2, 3])

pd.concat([ser1, ser2])

- 0 1 1 A D 2 B E 3 C F

  • 0 1 1 A NaN 2 B NaN 3 C NaN 4 NaN D 5 NaN E 6 NaN F
  • 1 A 2 B 3 C 4 D 5 E 6 F dtype: object
  • 1 A 2 B 3 C 1 D 2 E 3 F dtype: object ✔✔1 A

2 B

3 C

1 D

2 E

3 F

dtype: object

When concatenating two data frames, to restrict the result to the common columns, we can use the option

  • join='inner'
  • stats()
  • descriptives() ✔✔describe()

T/F: An essential piece of analysis of large data is efficient summarization by computing aggregations like sum(), mean(), median(), min(), and max(), ✔✔True

To aggregate data in Pandas we use the function:

  • sql
  • stats
  • groupby
  • aggregate ✔✔groupby

The three steps in a groupby operation are

  • group, by, display
  • inform, transform, storm
  • divide, invade, conquer
  • split, apply, combine ✔✔split, apply, combine

To convert a column of string values to multiple columns of numerical values, we use

  • get_indicators() method
  • get_dummies() method
  • stack() method
  • unstack() method ✔✔get_dummies() method

One advantage of Pandas vectorized string compared to built-in string methods is

  • their implementation in many languages
  • Graciously handling missing values
  • being more efficient in using memory resources
  • the capacity to handle longer strings ✔✔Graciously handling missing values

T/F: Slicing is not allowed in Pandas vectorized string operations ✔✔False

T/F: Nearly all Python's built-in string methods are mirrored by a Pandas vectorized string method. ✔✔True

T/F: Regular expressions are supported in Pandas vectorized string operations ✔✔True

Time deltas reference

  • time periods of a uniform length
  • particular moments in time
  • an exact length of time
  • finite size time series ✔✔an exact length of time

The difference between time intervals and periods

  • Periods usually reference a special case of time intervals in which each interval is of uniform length and does not overlap
  • Time periods are supported by pandas but intervals are not
  • Periods have longer time deltas than intervals
  • There is no difference, the two are synonymous ✔✔Periods usually reference a special case of time intervals in which each interval is of uniform length and does not overlap

The difference between two Timestamp values is a value of the following time:

  • Timerange
  • Timeperiod
  • Timeinterval
  • Timedelta ✔✔Timedelta

To create a Timestamp object from a string 'May 18 2019'

  • overheating the server
  • overfetching data from the server
  • over engineering the code
  • overclocking the CPU ✔✔overfetching data from the server

XML organizes data in a

  • Fractal multi-dimensional structure
  • Flat blockchain structure
  • Hierarchical tree-like structure
  • Interconnected network-like structure ✔✔Hierarchical tree-like structure

T/F: XQUERY and XPATH are incompatible ✔✔False

T/F: the structure of the XML document is specified with its nested attributes ✔✔False

T/F: In XML, tags can have optional attributes ✔✔True

T/F: XQuery for XML is like SQL for databases ✔✔True

HTML stands for:

  • HoloText Machine Language
  • HyperText Markup Language
  • HyperText Markdown Language
  • HoverText Markup Language ✔✔HyperText Markup Language

Which BeautifulSoup method can find all the instances of a tag on a page

  • extract
  • find_all
  • sip_soup
  • locate_tag ✔✔find_all

HTML tag classes and ids are:

  • created by web developers to avoid name conflict
  • used by CSS to determine which HTML elements to apply certain styles to
  • needed to render the HTML content in a mobile browser
  • translated into Python types and variables ✔✔used by CSS to determine which HTML elements to apply certain styles to

Which Python package is used to parse an HTML document

  • HTMLCracker
  • urllib
  • requests
  • BeautifulSoup ✔✔BeautifulSoup

When two tags are nested within the same parent tag, they are an example of a ____ relationship

  • parent
  • sibling
  • child
  • brotherhood ✔✔sibling

T/F: In Altair, it is possible to aggregate data before plotting it ✔✔True

In Altair, to add more details to how data is displayed, we can specify the ________

  • attributes
  • properties
  • channels
  • characteristics ✔✔channels

T/F: Nominal data are also called categorical data ✔✔True

T/F: Ordinal data consist of values that have a specific ordering ✔✔True

T/F: Nominal data consist of values that have a specific ordering ✔✔False

Which of the following can be thought of as ordinal data?

  • Date of birth
  • Letter grades (e.g., A, A-, B+ ...)
  • Movie genre (e.g., Action, Comedy, ...)
  • Height ✔✔Letter grades (e.g., A, A-, B+ ...)

T/F: Morpohology refers to how words get modified to change their meaning with prefixes and suffixes. ✔✔True

T/F: A sentence has nested structured that is composed with phrases with their own structures ✔✔True

T/F: "Lemmatizing" a text is the process of going through the text and replacing each word with its lemma. ✔✔True

The rules for taking a singular noun and turning it into a plural noun are:

  • Lemmatization
  • TextBlob
  • one to many relationship
  • Pluralization ✔✔Pluralization

T/F: TextBlob builds on top of NLTK ✔✔True

T/F: spaCy's models are rule-based and the decisions they made reflect the expertise of linguists who programmed them ✔✔False

Which one of the following is not an example of a named entity?

  • $1,000,
  • Athens, GA
  • creative thinking
  • September 24th, 2019 ✔✔creative thinking

spaCy determines the similarity of two words by

  • examining their definition in the Oxford English Dictionary
  • counting the number of characters in each
  • using ==
  • comparing their word vectors ✔✔comparing their word vectors

Which of the following features is not supported by spaCy?

  • Sentiment analysis
  • Part-of-speech tagging
  • Named entity recognition
  • Tokenization ✔✔Sentiment analysis

T/F: spaCy supports out-of-the-box chat function ✔✔False

T/F: Network characteristics are particular to the domains in which these networks are found ✔✔False

T/F: The emergence of network science can be traced to the efforts of scholars in multiple disciplines charting network maps ✔✔True

  • Nodes and links
  • Length and width
  • Capacity and bandwidth ✔✔Nodes and links

Which property represents the number of links a node has to other nodes

  • clustering
  • outreach
  • density
  • degree ✔✔degree

Network density is

  • The ratio of actual edges in the network to all possible edges in the network
  • The ratio of actual nodes in the network to actual edges in the network
  • The ratio of actual edges in the network to actual nodes in the network
  • The ratio of actual nodes in the network to all possible edges in the network ✔✔The ratio of actual edges in the network to all possible edges in the network

If a node has three lines extending from it to other nodes, its degree is:

  • 1
  • 2
  • 4
  • 3 ✔✔ 3

T/F: NetworkX allows you to add attributes to both nodes and edges ✔✔True

In NetworkX, which function is used to get basic information about a network

  • info
  • describe
  • print
  • summary ✔✔info

What object in NetworkX is used to create an undirected network?

  • UnNetwork
  • Network
  • Graph
  • UnGraph ✔✔Graph

Histograms are useful to show

  • the association between different dimensions of the data
  • the distribution of the data
  • the number of attributes in the data
  • the size of the data ✔✔the distribution of the data

T/F: The window transform performs calculations over sorted groups of data records ✔✔True

Grouping continuous data into discrete groups is called:

  • coarsening
  • grouping
  • binning
  • thresholding ✔✔binning

T/F: The filter transform creates a new table with a subset of the original data, removing rows that fail to meet a provided predicate test ✔✔True

T/F: Altair provides various functions to aggregate data before plotting it ✔✔true