NumPy / Pandas / scikit-learn Interview Questions Hindi mein

NumPy / Pandas / scikit-learn कोर्स के 25 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

NumPy Arrays

1. What do all elements of a NumPy array share?

  1. A Python object type per element
  2. A single value
  3. A single dtype
  4. Nothing in particular
जवाब देखें

जवाब: A single dtype

One dtype enables fast, compact storage.

पाठ: Creating and Shaping Arrays

2. Can a (2, 3) array be added to a (3,) array?

  1. Yes, the (3,) array is broadcast across each row
  2. No, shapes must be identical
  3. Only if both are float
  4. Only with a loop
जवाब देखें

जवाब: Yes, the (3,) array is broadcast across each row

Trailing dimensions match.

पाठ: Vectorised Maths and Broadcasting

3. Which operation returns a view sharing memory with the original?

  1. np.copy(a)
  2. A boolean mask
  3. Fancy indexing with a list
  4. A basic slice such as a[1:4]
जवाब देखें

जवाब: A basic slice such as a[1:4]

Slices are views; masks and lists copy.

पाठ: Indexing, Masks, Views and Copies

Computing With NumPy

4. What does scores.mean(axis=0) return for a students-by-exams matrix?

  1. The mean of each student (row)
  2. The mean of each exam (column)
  3. A single overall mean
  4. The median
जवाब देखें

जवाब: The mean of each exam (column)

axis=0 collapses rows.

पाठ: Aggregation and Random Numbers

5. What is np.mean([1.0, np.nan, 3.0])?

  1. 2.0
  2. nan
  3. 4.0
  4. An error
जवाब देखें

जवाब: nan

NaN spreads; use np.nanmean to ignore it.

पाठ: Floating Point, Overflow and NaN

6. Why can a looped sum and np.dot differ slightly?

  1. Loops round to integers
  2. np.dot is wrong
  3. Python ints are inexact
  4. They add the numbers in a different order, and floating-point addition is not exactly associative
जवाब देखें

जवाब: They add the numbers in a different order, and floating-point addition is not exactly associative

Compare floats with a tolerance.

पाठ: Vectorisation Instead of Loops

pandas Fundamentals

7. What does each DataFrame column have?

  1. Its own dtype
  2. The same dtype as all other columns
  3. No dtype
  4. A separate index per row
जवाब देखें

जवाब: Its own dtype

Columns are typed Series.

पाठ: Series and DataFrames

8. Which selects rows by integer position?

  1. query
  2. loc
  3. iloc
  4. at with labels
जवाब देखें

जवाब: iloc

i for integer position.

पाठ: Selecting Rows and Columns

9. What does an empty numeric field in a CSV become after read_csv?

  1. An empty string in a float column
  2. 0
  3. NaN
  4. An error
जवाब देखें

जवाब: NaN

Missing values become NaN.

पाठ: Reading and Writing Data

Cleaning Data With pandas

10. What does df.dropna() do by default?

  1. Drops every row that has any missing value
  2. Fills missing values with 0
  3. Drops columns only
  4. Nothing unless inplace=True
जवाब देखें

जवाब: Drops every row that has any missing value

Often too aggressive; use subset.

पाठ: Handling Missing Values

11. What does errors="coerce" do in pd.to_numeric?

  1. Converts to strings
  2. Raises an error for bad values
  3. Deletes the column
  4. Turns unparseable values into NaN
जवाब देखें

जवाब: Turns unparseable values into NaN

Bad values become missing.

पाठ: Types, Strings and Categories

12. In pandas 3, how do you set column b to 0 where a > 1 in df?

  1. df[df["a"] > 1]["b"] = 0
  2. df.loc[df["a"] > 1, "b"] = 0
  3. subset = df[df["a"] > 1]; subset["b"] = 0
  4. df.b.iloc = 0
जवाब देखें

जवाब: df.loc[df["a"] > 1, "b"] = 0

One loc call on the original.

पाठ: Copy-on-Write in pandas 3

Analysing Data With pandas

13. Which groupby method returns results aligned to the original rows?

  1. agg
  2. transform
  3. size
  4. describe
जवाब देखें

जवाब: transform

Same length as the input.

पाठ: Grouping and Aggregating

14. Which join keeps every order even if the customer is unknown?

  1. concat with axis=1
  2. An inner join
  3. A right join from orders
  4. A left join from orders
जवाब देखें

जवाब: A left join from orders

Left keeps all left rows.

पाठ: Merging and Concatenating

15. What happens to duplicate (month, city) pairs in pivot_table?

  1. They are combined with the aggregation function
  2. They raise an error
  3. Only the first is kept
  4. They become new columns
जवाब देखें

जवाब: They are combined with the aggregation function

pivot_table aggregates; pivot would fail.

पाठ: Pivot Tables and Reshaping

16. What does resample("W") do by default?

  1. Shifts dates by a week
  2. Keeps one row per weekday
  3. Aggregates into weeks ending on Sunday
  4. Removes weekends
जवाब देखें

जवाब: Aggregates into weeks ending on Sunday

Weekly bins, W-SUN.

पाठ: Working With Time Series

Machine Learning With scikit-learn

17. Why use stratify=y in train_test_split?

  1. To remove outliers
  2. To make training faster
  3. To keep class proportions the same in train and test sets
  4. To scale features
जवाब देखें

जवाब: To keep class proportions the same in train and test sets

Stratification preserves class balance.

पाठ: The Estimator API

18. Which metric measures how many actual positives the model found?

  1. Recall
  2. Precision
  3. Accuracy
  4. Support
जवाब देखें

जवाब: Recall

Recall = found positives / all positives.

पाठ: Classification Metrics

19. What does an R² of 0 mean?

  1. The data has no variance
  2. The model is perfect
  3. The model predicts zero
  4. The model is no better than predicting the mean
जवाब देखें

जवाब: The model is no better than predicting the mean

R² compares to the mean baseline.

पाठ: Regression and Baselines

Pipelines and Model Selection

20. What does handle_unknown="ignore" do in OneHotEncoder?

  1. Drops the whole row
  2. Encodes unseen categories as all zeros instead of raising an error
  3. Adds a new column at predict time
  4. Raises a warning and stops
जवाब देखें

जवाब: Encodes unseen categories as all zeros instead of raising an error

Robust to new categories.

पाठ: Pipelines and ColumnTransformer

21. Which splitter suits data ordered in time?

  1. Random KFold with shuffling
  2. TimeSeriesSplit
  3. StratifiedKFold
  4. LeaveOneOut on shuffled data
जवाब देखें

जवाब: TimeSeriesSplit

Never train on the future.

पाठ: Cross-Validation

22. How do you name the C parameter of an SVC step called "svc" in a pipeline grid?

  1. pipeline_C
  2. C
  3. svc.C
  4. svc__C
जवाब देखें

जवाब: svc__C

step__parameter.

पाठ: Hyperparameter Search

Avoiding Pitfalls and Shipping Models

23. How do you prevent leakage from feature selection or scaling?

  1. Put them in a Pipeline so they are fitted only on training folds
  2. Apply them to all data before splitting
  3. Skip cross-validation
  4. Use a larger test set only
जवाब देखें

जवाब: Put them in a Pipeline so they are fitted only on training folds

Fit preprocessing on training data only.

पाठ: Data Leakage

24. Why should you never load a pickled model from an untrusted source?

  1. It deletes training data
  2. It is always too large
  3. Unpickling can execute arbitrary code
  4. It changes the model's accuracy
जवाब देखें

जवाब: Unpickling can execute arbitrary code

Pickle is not a safe format for untrusted input.

पाठ: Saving and Loading Models

25. Which item belongs on a data science checklist?

  1. Scale data before splitting
  2. Tune hyperparameters on the test set
  3. Compare the model to a dummy baseline
  4. Ignore missing values
जवाब देखें

जवाब: Compare the model to a dummy baseline

A baseline shows whether the model adds value.

पाठ: A Data Science Workflow Checklist

← कोर्स पर वापस जाएँ