Affine
40+ Interview Questions and Answers
Q1. you have a pandas dataframe with three columns, filled with state names, city names and arbitrary numbers respectively. How to retrieve top 2 cities per state. (top according to the max number in the third colu...
read moreRetrieve top 2 cities per state based on max number in third column of pandas dataframe.
Group the dataframe by state column
Sort each group by the third column in descending order
Retrieve the top 2 rows of each group using head(2) function
Concatenate the resulting dataframes using pd.concat() function
Q2. I have two jars of 5 litres and 3 litres. How can I measure 4 litres? (Assume: Infinite supply of water and no third jar is present)
Fill the 3L jar and pour it into the 5L jar. Repeat the process with 3L jar and stop when 5L jar has 4L water.
Fill 3L jar and pour it into 5L jar
Repeat the process until 5L jar has 4L water
4L can be measured by filling 3L jar twice and pouring it into 5L jar until it reaches 4L
Q3. How to retain special characters (that pandas discards by default) in the data while reading it?
To retain special characters in pandas data, use encoding parameter while reading the data.
Use encoding parameter while reading the data in pandas
Specify the encoding type of the data file
Example: pd.read_csv('filename.csv', encoding='utf-8')
Q4. how will the resultant table be, when you "merge" two tables that match at a column. and the second table has many of keys repeated.
The resultant table will have all the columns from both tables and the rows will be a combination of matching rows.
The resultant table will have all the columns from both tables
The rows in the resultant table will be a combination of matching rows
If the second table has repeated keys, there will be multiple rows with the same key in the resultant table
Q5. How to read large .csv files in pandas quickly?
Use pandas' read_csv() method with appropriate parameters to read large .csv files quickly.
Use the chunksize parameter to read the file in smaller chunks
Use the low_memory parameter to optimize memory usage
Use the dtype parameter to specify data types for columns
Use the usecols parameter to read only necessary columns
Use the skiprows parameter to skip unnecessary rows
Use the nrows parameter to read only a specific number of rows
Use the na_values parameter to specify values to...read more
Q6. how does look up happens in a list when you do my_list[5]?
my_list[5] retrieves the 6th element of the list.
Indexing starts from 0 in Python.
The integer inside the square brackets is the index of the element to retrieve.
If the index is out of range, an IndexError is raised.
Q7. what is the purpose of lambda function when regural functions(of def) exist? how are they different?
Lambda functions are anonymous functions used for short and simple operations. They are different from regular functions in their syntax and usage.
Lambda functions are defined without a name and keyword 'lambda' is used to define them.
They can take any number of arguments but can only have one expression.
They are commonly used in functional programming and as arguments to higher-order functions.
Lambda functions are often used for short and simple operations that do not requir...read more
Q8. how to create dictionaries in python with repeated keys?
To create dictionaries in Python with repeated keys, use defaultdict from the collections module.
Import the collections module
Create a defaultdict object
Add key-value pairs to the dictionary using the same key multiple times
Access the values using the key
Example: from collections import defaultdict; d = defaultdict(list); d['key'].append('value1'); d['key'].append('value2')
Q9. explain eign vectors and eign values? what purpose do they serve in ML?
Eigenvalues and eigenvectors are linear algebra concepts used in machine learning for dimensionality reduction and feature extraction.
Eigenvalues represent the scaling factor of the eigenvectors.
Eigenvectors are the directions along which a linear transformation acts by stretching or compressing.
In machine learning, eigenvectors are used for principal component analysis (PCA) to reduce the dimensionality of data.
Eigenvalues and eigenvectors are also used in image processing f...read more
Q10. How do perform the manipulations quicker in pandas?
Use vectorized operations, avoid loops, and optimize memory usage.
Use vectorized operations like apply(), map(), and applymap() instead of loops.
Avoid using iterrows() and itertuples() as they are slower than vectorized operations.
Optimize memory usage by using appropriate data types and dropping unnecessary columns.
Use inplace=True parameter to modify the DataFrame in place instead of creating a copy.
Use the pd.eval() function to perform arithmetic operations on large DataFr...read more
Q11. explain PCA briefly? what can it be used for and what can it not be used for?
PCA is a dimensionality reduction technique used to transform high-dimensional data into a lower-dimensional space.
PCA can be used for feature extraction, data visualization, and noise reduction.
PCA cannot be used for causal inference or to handle missing data.
PCA assumes linear relationships between variables and may not work well with non-linear data.
PCA can be applied to various fields such as finance, image processing, and genetics.
Q12. Why Data anayltics? Why not a technical job in your field?
Data analytics allows me to use my technical skills to solve business problems and make data-driven decisions.
Data analytics helps me to identify patterns and trends in data that can be used to improve business processes.
It allows me to work with large datasets and use statistical methods to extract insights.
I can use my technical skills to develop and implement data models and algorithms.
Data analytics is a growing field with many opportunities for career advancement.
Example...read more
Q13. do we minimize or maximize the loss in logistic regression?
We minimize the loss in logistic regression.
The goal of logistic regression is to minimize the loss function.
The loss function measures the difference between predicted and actual values.
The optimization algorithm tries to find the values of coefficients that minimize the loss function.
Minimizing the loss function leads to better model performance.
Examples of loss functions used in logistic regression are cross-entropy and log loss.
Q14. If I keep two diodes in series will it work as a transistor? (EC branch)
No, two diodes in series cannot work as a transistor.
Transistors have three terminals while diodes have two.
Transistors can amplify signals while diodes cannot.
Transistors can be used as switches while diodes cannot.
Diodes in series will only increase the voltage drop.
Transistors have different modes of operation such as common emitter, common base, and common collector.
Q15. Why do you want to join Affine Analytics?
I am excited to join Affine Analytics because of their reputation for delivering innovative solutions and their focus on employee growth.
Affine Analytics has a strong track record of delivering cutting-edge solutions to clients across industries.
I am impressed by the company's commitment to employee growth and development, as evidenced by their training and mentorship programs.
I am excited about the opportunity to work with a talented and diverse team of professionals at Affi...read more
Q16. how does one vs rest work for logistic regression?
One vs Rest is a technique used to extend binary classification to multi-class problems in logistic regression.
It involves training multiple binary classifiers, one for each class.
In each classifier, one class is treated as the positive class and the rest as negative.
The class with the highest probability is predicted as the final output.
It is also known as one vs all or one vs others.
Example: In a 3-class problem, we train 3 binary classifiers: class 1 vs rest, class 2 vs re...read more
Q17. What is the difference between Tree Map and Heatmap in Tableau?
Tree Map visualizes hierarchical data using nested rectangles, while Heatmap displays data values using color gradients.
Tree Map displays data hierarchically with nested rectangles, where the size and color represent different measures.
Heatmap visualizes data values using color gradients, with darker colors indicating higher values.
Tree Map is useful for showing hierarchical data structures, while Heatmap is effective for comparing values across categories.
Example: Tree Map c...read more
Q18. What is the difference between 'Extract Data' and 'Live Connection' in Tableau?
Extract Data saves a snapshot of data in Tableau workbook, while Live Connection directly connects to data source.
Extract Data creates a static copy of data in Tableau workbook, while Live Connection directly queries data source in real-time.
Extract Data is useful for working offline or with small datasets, while Live Connection is ideal for large datasets or when data is frequently updated.
Extract Data can improve performance as it reduces the need to query the data source r...read more
Q19. what is one vs one classification?
One vs one classification is a binary classification method where multiple models are trained to classify each pair of classes.
It is used when there are more than two classes in the dataset.
It involves training multiple binary classifiers for each pair of classes.
The final prediction is made by combining the results of all the binary classifiers.
Example: In a dataset with 5 classes, 10 binary classifiers will be trained for each pair of classes.
Q20. what is VIF and how is it calculated?
VIF stands for Variance Inflation Factor, a measure of multicollinearity in regression analysis.
VIF is calculated for each predictor variable in a regression model.
It measures how much the variance of the estimated regression coefficient is increased due to multicollinearity.
A VIF of 1 indicates no multicollinearity, while a VIF greater than 1 indicates increasing levels of multicollinearity.
VIF is calculated as 1 / (1 - R^2), where R^2 is the coefficient of determination fro...read more
Q21. what is AIC & BIC in linear regression?
AIC & BIC are statistical measures used to evaluate the goodness of fit of a linear regression model.
AIC stands for Akaike Information Criterion and BIC stands for Bayesian Information Criterion.
Both AIC and BIC are used to compare different models and select the best one.
AIC penalizes complex models less severely than BIC.
Lower AIC/BIC values indicate a better fit of the model to the data.
AIC and BIC can be calculated using the log-likelihood function and the number of param...read more
Q22. How frequently do you play Badminton? (Hobby)
I play badminton twice a week as a hobby.
I enjoy playing badminton as a way to stay active and relieve stress.
I usually play with friends or family members at a local community center.
I have been playing badminton for several years and have improved my skills over time.
Q23. Given an input string "neeraj chopra" Write Python code to get output string as "jareen arpohc".
The Python code to get the output string as 'jareen arpohc' from the input string 'neeraj chopra' is provided.
Split the input string into individual words
Reverse each word
Join the reversed words with a space in between
Q24. explain generators and decorators in python
Generators are functions that allow you to iterate over a sequence of values without creating the entire sequence in memory. Decorators are functions that modify the behavior of other functions.
Generators use the yield keyword to return values one at a time
Generators are memory efficient and can handle large datasets
Decorators are functions that take another function as input and return a modified version of that function
Decorators can be used to add functionality to existing...read more
Q25. What is the order of execution of an SQL query?
The order of execution of an SQL query involves multiple steps to retrieve data from a database.
1. Parsing: The SQL query is first parsed to check for syntax errors.
2. Optimization: The query optimizer creates an execution plan to determine the most efficient way to retrieve data.
3. Compilation: The optimized query is compiled into an executable form.
4. Execution: The compiled query is executed by the database engine to retrieve the requested data.
5. Fetching: The retrieved d...read more
Q26. What is 'Data Validation' in Excel?
Data Validation in Excel ensures that data entered in a cell meets certain criteria or conditions.
Data Validation allows you to set rules for what can be entered in a cell, such as a range of values, a list of items, or a custom formula.
Examples of Data Validation include setting a drop-down list of options for a cell, restricting input to a certain number range, or ensuring dates are entered in a specific format.
Data Validation helps maintain data accuracy and consistency in...read more
Q27. A revolver with 2 bullets puzzle
A puzzle involving a revolver with 2 bullets.
The puzzle involves a revolver with 2 bullets and a person who spins the chamber and pulls the trigger twice.
The question usually asks what is the probability of the person surviving or getting shot.
The answer depends on the number of chambers in the revolver and whether the bullets are in consecutive chambers or not.
Q28. what are Joins in SQL, explain different joins and their outputs
Joins in SQL are used to combine rows from two or more tables based on a related column between them.
Types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN
INNER JOIN returns rows when there is at least one match in both tables
LEFT JOIN returns all rows from the left table and the matched rows from the right table
RIGHT JOIN returns all rows from the right table and the matched rows from the left table
FULL JOIN returns rows when there is a match in one of the t...read more
Q29. SQL and domain - Use case scenarios and real time examples
SQL is used in various domains for data analysis and reporting. Use cases include financial analysis, inventory management, and customer relationship management.
Financial analysis - using SQL to analyze revenue, expenses, and profitability
Inventory management - tracking stock levels, orders, and shipments
Customer relationship management - analyzing customer data, preferences, and interactions
Q30. Given a list of 10 numbers. Write a code to list only even numbers out of the original list.
Code to list even numbers from a given list of 10 numbers.
Loop through the list of numbers
Check if each number is even using the modulo operator
If the number is even, add it to a new list of even numbers
Return the new list of even numbers
Q31. What is pivot table in Excel?
A pivot table in Excel is a data summarization tool that allows you to reorganize and summarize selected columns and rows of data.
Pivot tables allow you to analyze and summarize large amounts of data in a spreadsheet.
You can easily rearrange the layout of the data to view it from different perspectives.
Pivot tables can perform functions like sum, average, count, and more on the data.
They are useful for creating reports, charts, and dashboards based on the summarized data.
For ...read more
Q32. merge vs join in pandas
Merge and join are used to combine dataframes in pandas.
Merge is used to combine dataframes based on a common column or index.
Join is used to combine dataframes based on their index.
Merge can handle different column names, while join cannot.
Merge can handle different types of joins (inner, outer, left, right), while join only does inner join by default.
Q33. what is difference between DROP and TRUNCATE statements?
DROP deletes the table structure and data, while TRUNCATE deletes only the data.
DROP statement removes the table from the database, including all data and structure.
TRUNCATE statement removes all data from the table, but keeps the table structure intact.
DROP is a DDL (Data Definition Language) command, while TRUNCATE is a DML (Data Manipulation Language) command.
Q34. Reversal of string in python code
Reversing a string in Python code
Use slicing to reverse the string
Use the built-in function 'reversed()'
Convert the string to a list, reverse it, and then join it back to a string
Q35. What steps you’ll take to resolve a decline page visits trend
Q36. what is r squared value
R-squared value is a statistical measure that represents the proportion of the variance in the dependent variable that is predictable from the independent variable(s).
R-squared value ranges from 0 to 1, with 1 indicating a perfect fit.
It is used to evaluate the goodness of fit of a regression model.
A higher R-squared value indicates that the model explains a larger proportion of the variance in the dependent variable.
For example, an R-squared value of 0.8 means that 80% of th...read more
Q37. What are the types of data set you have worked upon?
I have worked on various types of data sets including sales data, customer data, financial data, and social media data.
Sales data
Customer data
Financial data
Social media data
Q38. Difference between Primary Key and Unique Key ?
Primary key uniquely identifies each record in a table, while Unique key allows only unique values but can have null values.
Primary key enforces uniqueness and not null constraint on a column
Primary key can consist of multiple columns
Unique key allows only unique values but can have null values
Unique key can be applied to multiple columns as well
Q39. Highlight the odd cells in excel
Use conditional formatting to highlight odd cells in Excel
Select the range of cells you want to highlight
Go to the 'Home' tab and click on 'Conditional Formatting'
Choose 'New Rule' and select 'Use a formula to determine which cells to format'
Enter the formula '=MOD(A1,2)=1' (assuming A1 is the top-left cell of your selected range)
Choose the formatting style you want for the odd cells
Q40. query to give running sum of salary
Use window function to calculate running sum of salary in SQL
Use window function like SUM() with OVER() clause
Partition the data by employee ID if needed
Order the data by date or any other relevant column
Q41. what are the different transformations you have used
I have used various transformations such as filtering, joining, aggregating, and pivoting in my data engineering projects.
Filtering data based on certain conditions
Joining multiple datasets together
Aggregating data to summarize information
Pivoting data from rows to columns or vice versa
Q42. Activity life cycle Factorial and fabbonacci series lateiniti var vs lazy Var vs val
Activity life cycle is a crucial concept in Android development. Factorial and Fibonacci series are common mathematical problems. lateinit var and lazy are used for initializing variables. Var and val are used for declaring variables.
Activity life cycle includes methods like onCreate, onStart, onResume, onPause, onStop, onDestroy.
Factorial is the product of all positive integers up to a given number. Example: 5! = 5*4*3*2*1 = 120.
Fibonacci series is a sequence where each numb...read more
Q43. what is a stored procedure
A stored procedure is a set of SQL statements that are stored in a database and can be called by other programs or scripts.
Stored procedures can improve performance by reducing network traffic and executing complex operations on the database server.
They can be used to encapsulate business logic and enforce security measures.
Example: CREATE PROCEDURE GetCustomerOrders AS SELECT * FROM Orders WHERE CustomerID = @CustomerID;
Q44. What is dual mode in Power BI
Dual mode in Power BI allows users to switch between DirectQuery and Import modes for data sources.
Dual mode allows users to combine the benefits of both DirectQuery and Import modes in Power BI.
Users can switch between DirectQuery and Import modes for different data sources within the same report.
DirectQuery mode connects directly to the data source for real-time data retrieval, while Import mode loads data into Power BI for faster performance.
For example, users can use Dire...read more
Q45. Write dax for delta sales growth
Calculate delta sales growth using DAX formula
Use the following DAX formula: Delta Sales Growth = (SUM(Sales[SalesAmount]) - CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH('Date'[DateKey]))) / CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH('Date'[DateKey]))
Make sure to replace 'Sales[SalesAmount]' with the actual column name in your dataset
Ensure that 'Date'[DateKey]' is the date column in your dataset
Q46. What is Accounts payable
Accounts payable is the amount of money a company owes to its suppliers or vendors for goods or services purchased on credit.
Accounts payable is a liability on the balance sheet
It represents the amount owed by the company to its creditors
It is typically recorded when goods or services are received but payment has not yet been made
Examples include invoices from suppliers for inventory purchases or services rendered
Q47. Joining tables with different joins
Joining tables with different joins in SQL
Use INNER JOIN to return rows when there is at least one match in both tables
Use LEFT JOIN to return all rows from the left table and the matched rows from the right table
Use RIGHT JOIN to return all rows from the right table and the matched rows from the left table
Use FULL JOIN to return rows when there is a match in one of the tables
Q48. Process of accounting in Tally
Accounting in Tally involves recording financial transactions, generating reports, and managing accounts.
Recording financial transactions such as sales, purchases, payments, and receipts
Generating financial statements like balance sheet, profit and loss statement
Managing accounts receivable and accounts payable
Creating and maintaining ledgers for different accounts
Reconciling bank statements with Tally entries
Generating various reports for analysis and decision-making
Top HR Questions asked in null
Interview Process at null
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month