question |
réponse |
What is the difference in data type consistency between a list and a Series? commencer à apprendre
|
|
A list can contain elements of different data types, whereas a Series is designed to hold elements of the same data type for more efficient processing.
|
|
|
How does indexing differ between a list and a Series? commencer à apprendre
|
|
A list is indexed by a range of integers starting from 0, while a Series can have custom index labels, not limited to integer positions.
|
|
|
What are the differences in functionality and methods between a list and a Series? commencer à apprendre
|
|
A list has basic functionality like adding, removing, or changing elements. A Series comes with more complex operations, including handling missing data, statistical operations, and time-series functionality.
|
|
|
Which has better performance for large datasets, a list or a Series? commencer à apprendre
|
|
A Series is optimized for performance, especially with large datasets, as it is built on top of NumPy, while lists are less efficient for such operations.
|
|
|
What is the difference in data alignment capabilities between a list and a Series? commencer à apprendre
|
|
Lists do not support data alignment features. Series support automatic data alignment based on index labels, useful in data analysis.
|
|
|
How does handling of missing data differ between a list and a Series? commencer à apprendre
|
|
Lists have no built-in support for handling missing data, while Series have integrated handling for missing data (like NaN values).
|
|
|
What are the library dependencies for lists and Series? commencer à apprendre
|
|
Lists are a core part of Python and require no additional libraries. Series are part of the pandas library, which must be installed and imported.
|
|
|
How do lists and Series differ in representing 2D data? commencer à apprendre
|
|
Lists can be nested to represent 2D data but lack special functionality. For 2D data, pandas uses a DataFrame, which is a collection of Series.
|
|
|
Which uses more memory, a list or a Series? commencer à apprendre
|
|
Generally, lists use more memory, while Series are more memory-efficient, especially for large datasets.
|
|
|
Do lists and Series support vectorized operations? commencer à apprendre
|
|
Lists do not support vectorized operations natively, while Series support vectorized operations, enhancing calculation efficiency across elements.
|
|
|
How do order and indexing differ between a list and a set? commencer à apprendre
|
|
Lists are ordered and support indexing; sets are unordered and do not support indexing.
|
|
|
Can lists and sets contain duplicate elements? commencer à apprendre
|
|
Lists can contain duplicates; sets automatically remove duplicates and only store unique elements.
|
|
|
How are lists and sets mutable? commencer à apprendre
|
|
Lists are mutable and can have elements added, removed, or changed. Sets are mutable in terms of adding or removing elements, but the elements themselves must be immutable.
|
|
|
What brackets are used to define lists and sets? commencer à apprendre
|
|
Lists are defined with square brackets [], while sets are defined with curly braces {} or the set() constructor for empty sets.
|
|
|
What types of elements can lists and sets contain? commencer à apprendre
|
|
Lists can contain different types, including other lists. Sets can only contain hashable (immutable) types and cannot have lists as elements.
|
|
|
What are the typical usages of lists and sets? commencer à apprendre
|
|
Lists are used for ordered sequences of items; sets are used for membership testing, removing duplicates, and set operations like unions and intersections.
|
|
|
How does performance in membership testing compare between a list and a set? commencer à apprendre
|
|
Membership testing is slower in lists as it scans the list, but faster in sets due to their hash table implementation.
|
|
|
What methods are unique to lists and sets? commencer à apprendre
|
|
Lists have methods like append(), extend(), insert(), pop(), remove(), etc. Sets have methods like add(), remove(), discard(), and set-specific operations like union(), intersection(), etc.
|
|
|
How do you define an empty list and an empty set? commencer à apprendre
|
|
An empty list is defined as [], while an empty set is defined as set().
|
|
|
What is the difference in element mutability between a list and a set? commencer à apprendre
|
|
Both lists and sets are mutable, but while list elements can be mutable, set elements must be immutable.
|
|
|