Complete the code to create a pandas Series with integer type.
import pandas as pd s = pd.Series([1, 2, 3], dtype=[1]) print(s.dtype)
Using "int64" sets the Series to integer type.
Complete the code to convert a pandas Series to float type.
import pandas as pd s = pd.Series([1, 2, 3]) s = s.astype([1]) print(s.dtype)
Using astype("float64") converts the Series to float type.
Fix the error in the code to create a DataFrame column with float type.
import pandas as pd df = pd.DataFrame({'A': [1, 2, 3]}) df['A'] = df['A'].astype([1]) print(df['A'].dtype)
To convert the column to float type, use "float64" with astype.
Fill both blanks to create a dictionary comprehension that maps words to their length only if length is greater than 3.
words = ['data', 'science', 'ai', 'ml'] lengths = {word: [1] for word in words if [2]
The dictionary maps each word to its length using len(word). The condition keeps words with length greater than 3 using len(word) > 3.
Fill all three blanks to create a dictionary comprehension that maps uppercase words to their length if length is greater than 2.
words = ['cat', 'dog', 'a', 'bird'] result = { [1]: [2] for w in words if [3] } print(result)
The dictionary keys are uppercase words using w.upper(). The values are their lengths using len(w). The condition filters words longer than 2 characters using len(w) > 2.