
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Vani Nalliappan has Published 130 Articles

Vani Nalliappan
455 Views
We can reshape a dataframe using melt(), stack(), unstack() and pivot() function.Solution 1Define a dataframe.Apply melt() function to convert wide dataframe column as rows. It is defined below, df.melt()ExampleLet’s see the below code to get a better understanding −import pandas as pd df = pd.DataFrame({'Id':[1, 2, 3], 'Age':[13, 14, 13], ... Read More

Vani Nalliappan
84 Views
Input −Assume you have a DataFrame, and the result for shifting the first column and fill the missing values are, one two three 0 1 10 100 1 2 20 200 2 3 30 300 enter the value 15 one two three 0 15 1 10 ... Read More

Vani Nalliappan
327 Views
Assume you have a dataframe with time series data and the result for truncated data is, before truncate: Id time_series 0 1 2020-01-05 1 2 2020-01-12 2 3 2020-01-19 3 4 2020-01-26 4 5 2020-02-02 5 6 2020-02-09 6 7 2020-02-16 7 8 2020-02-23 8 9 2020-03-01 9 10 2020-03-08 ... Read More

Vani Nalliappan
263 Views
Assume, you have series and the result for autocorrelation with lag 2 is, Series is: 0 2.0 1 10.0 2 3.0 3 4.0 4 9.0 5 10.0 6 2.0 7 NaN 8 3.0 dtype: float64 series correlation: -0.4711538461538461 series correlation ... Read More

Vani Nalliappan
204 Views
Assume you have a dataframe and the result for exporting into pickle file and read the contents from file as, Export to pickle file: Read contents from pickle file: Fruits City 0 Apple Shimla 1 Orange Sydney 2 Mango Lucknow 3 Kiwi WellingtonSolutionTo solve ... Read More

Vani Nalliappan
1K+ Views
Assume you have the following sample json data stored in a file as pandas_sample.json{ "employee": { "name": "emp1", "salary": 50000, "age": 31 } }The result for after converting to csv as, , employee age, 31 name, emp1 salary, 50000SolutionTo ... Read More

Vani Nalliappan
197 Views
Assume, you have time series and the result for maximum month-end frequency, DataFrame is: Id time_series 0 1 2020-01-05 1 2 2020-01-12 2 3 2020-01-19 3 4 2020-01-26 4 5 2020-02-02 5 6 2020-02-09 6 7 2020-02-16 7 8 2020-02-23 8 9 2020-03-01 9 10 2020-03-08 Maximum month end frequency: ... Read More

Vani Nalliappan
2K+ Views
Assume, we have already saved pandas.csv file and export the file to Html formatSolutionTo solve this, we will follow the steps given below −Read the csv file using the read_csv method as follows −df = pd.read_csv('pandas.csv')Create new file pandas.html in write mode using file object, f = open('pandas.html', 'w')Declare result ... Read More

Vani Nalliappan
1K+ Views
Assume, you have an Excel file stored with the name of pandas.xlsx in your location.SolutionTo solve this, we will follow the steps given below −Define pd.read_excel method to read data from pandas.xlsx file and save it as dfdf = pd.read_excel('pandas.xlsx')Apply df.iloc[:, 0] to print all rows of first columndf.iloc[:, 0]Apply ... Read More

Vani Nalliappan
2K+ Views
Assume you have the following data in your csv file and save it as pandas.csv.pandas.csvId, Data 1, 11 2, 22 3, 33 4, 44 5, 55 6, 66 7, 77 8, 88 9, 99 10, 100The result for sum of last two records as, Sum of last two rows: Id ... Read More