Python Foundation

+91-7982108418            
  1. Write a Pandas program to display the default index and set a column as an Index in a given dataframe.

Test Data:

0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
  • Write a Pandas program to create a multi Index frame using two columns and using an Index and a
column. 
Test Data:
0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
Test Data:   0 s001 V Alberto Franco 15/05/2002 35 street1 t1 1 s002 V Gino Mcneill 17/05/2002 32 street2 t2 2 s003 VI Ryan Parkes 16/02/1999 33 street3 t3 3 s001 VI Eesha Hinton 25/09/1998 30 street1 t4 4 s002 V Gino Mcneill 11/05/2002 31 street2 t5 5 s004 VI David Parkes 15/09/1997 32 street4 t6    

Write a Pandas program to display the default index and set a column as an Index in a given dataframe and then reset the index.

Test Data:   0 s001 V Alberto Franco 15/05/2002 35 street1 t1 1 s002 V Gino Mcneill 17/05/2002 32 street2 t2 2 s003 VI Ryan Parkes 16/02/1999 33 street3 t3 3 s001 VI Eesha Hinton 25/09/1998 30 street1 t4 4 s002 V Gino Mcneill 11/05/2002 31 street2 t5 5 s004 VI David Parkes 15/09/1997 32 street4 t6    

Write a Pandas program to create an index labels by using 64-bit integers, using floating-point numbers in a given dataframe.

  • Write a Pandas program to create a DataFrame using intervals as an index.
  • Write a Pandas program to create a dataframe indexing by date and time.

Test Data:

0s001VAlberto Franco15/05/200235 street1t1
1s002VGino Mcneill17/05/200232 street2t2
2s003VIRyan Parkes16/02/199933 street3t3
3s001VIEesha Hinton25/09/199830 street1t4
4s002VGino Mcneill11/05/200231 street2t5
5s004VIDavid Parkes15/09/199732 street4t6
  • Write a Pandas program to create a dataframe and set a title or name of the index column.
Test Data: 
0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
  • Write a Pandas program to set value in a specific cell in a given dataframe using index.
Test Data: 
0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
  • Write a Pandas program to convert index of a given dataframe into a column.
Test Data: 
0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
  1. Write a Pandas program to convert 1st and 3rd levels in the index into columns from a multiple level of index frame of a given dataframe.

Test Data:

0s001V Alberto Franco15/05/200235 street1t1
1s002V    Gino Mcneill17/05/200232 street2t2
2s003VI     Ryan Parkes16/02/199933 street3t3
3s001VI    Eesha Hinton25/09/199830 street1t4
4s002VGino Mcneill11/05/200231 street2t5
5s004VIDavid Parkes15/09/199732 street4t6
  1. Write a Pandas program to check if a specified value exists in single and multiple column index dataframe.

Test Data:

0s001VAlberto Franco15/05/200235 street1t1
1s002VGino Mcneill17/05/200232 street2t2
2s003VIRyan Parkes16/02/199933 street3t3
3s001VIEesha Hinton25/09/199830 street1t4
4s002VGino Mcneill11/05/200231 street2t5
5s004VIDavid Parkes15/09/199732 street4t6
  1. Write a Pandas program to construct a series using the MultiIndex levels as the column and index.
  1. Write a Pandas program to construct a DataFrame using the MultiIndex levels as the column and index.
  1. Write a Pandas program to extract a single row, rows and a specific value from a MultiIndex levels DataFrame.
  1. Write a Pandas program to rename names of columns and specific labels of the Main Index of the MultiIndex dataframe.
  1. Write a Pandas program to sort a MultiIndex of a DataFrame. Also sort on various levels of index.
  1. Write a Pandas program to extract elements in the given positional indices along an axis of a dataframe.
  1. Write a Pandas program to get the index of an element of a given Series.
  1. Write a Pandas program to select a specific row of given series/dataframe by integer index.

Test Data:

0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
  • Write a Pandas program to find the indexes of rows of a specified value of a given column in a
DataFrame. 
Test Data:
0s001VAlberto Franco15/05/200235street1t1
1s002VGino Mcneill17/05/200232street2t2
2s003VIRyan Parkes16/02/199933street3t3
3s001VIEesha Hinton25/09/199830street1t4
4s002VGino Mcneill11/05/200231street2t5
5s004VIDavid Parkes15/09/199732street4t6
  • Write a Pandas program to drop a index level from a multi-level column index of a dataframe.
  • Write a Pandas program to insert a column at a specific index in a given DataFrame.
  • Write a Pandas program to print a DataFrame without index.
  • Write a Pandas program to find integer index of rows with missing data in a given dataframe.
  • Write a Pandas program to start index with different value rather than 0 in a given DataFrame.
  • Write a Pandas program to select rows by filtering on one or more column(s) in a multi-index dataframe.

Merging & Joining

  1. Write a Pandas program to join the two given dataframes along rows and assign all data.

Test Data:

student_data1:

student_id              name marks

  • S1 Danniella Fenton    200
  • S2      Ryder Storey    210
  • S3      Bryce Jensen    190
  • S4         Ed Bernal    222
  • S5       Kwame Morin    199

student_data2:

student_id              name marks

  • S4 Scarlette Fisher    201
  • S5 Carla Williamson    200
  • S6       Dante Morse    198
  • S7    Kaiser William    219
  • S8   Madeeha Preston    201
  • Write a Pandas program to join the two given dataframes along columns and assign all data.

Test Data:

student_data1:

student_id              name marks

0S1DanniellaFenton200
1S2RyderStorey210
2S3BryceJensen190
3S4EdBernal222
4S5Kwame Morin199
student_data2: student_id              name marks
0S4Scarlette Fisher201
1S5Carla Williamson200
2S6Dante Morse198
3S7Kaiser William219
4S8Madeeha Preston201
  • Write a Pandas program to append rows to an existing DataFrame and display the combined data.

Test Data:

tudent_data1

student_id              name marks

  • S1 Danniella Fenton    200
  • S2      Ryder Storey    210
  • S3      Bryce Jensen    190
  • S4         Ed Bernal    222
  • S5       Kwame Morin    199

New Row(s)

student_id                  S6

name          Scarlette Fisher

marks                      205

dtype: object

  • Write a Pandas program to append a list of dictioneries or series to a existing DataFrame and display the combined data.

Test Data:

student_idnamemarks
0         S1Danniella Fenton200
1         S2Ryder Storey210
2         S3Bryce Jensen190
3         S4Ed Bernal222
4         S5Kwame Morin199
Dictionary:  
student_idS6 
nameScarlette Fisher 
marks dtype: object205 
  • Write a Pandas program to join the two given dataframes along rows and merge with another dataframe along the common column id.
  • Write a Pandas program to join the two dataframes using the common column of both dataframes.

Test Data:

student_data1:

student_id              name marks

0S1Danniella Fenton    200
1S2Ryder Storey    210
2S3Bryce Jensen    190
3S4Ed Bernal222
4S5Kwame Morin199
student_data2: student_id              name marks
0S4Scarlette Fisher201
1S5Carla Williamson200
2S6Dante Morse198
3S7Kaiser William219
4S8Madeeha Preston201
  • Write a Pandas program to join the two dataframes with matching records from both sides where available.

Test Data:

student_data1:

student_id              name marks

  • S1 Danniella Fenton    200
  • S2      Ryder Storey    210
  • S3      Bryce Jensen    190
  • S4         Ed Bernal    222
  • S5       Kwame Morin    199

student_data2:

student_id              name marks

  • S4 Scarlette Fisher    201
  • S5 Carla Williamson    200
  • S6       Dante Morse    198
  • S7    Kaiser William    219
  • S8   Madeeha Preston    201
  • Write a Pandas program to join (left join) the two dataframes using keys from left dataframe only.

Test Data:

data1:

key1 key2     P    Q 0  K0   K0 P0 Q0

  1. K0   K1 P1 Q1
  2. K1   K0 P2 Q2
  3. K2   K1 P3 Q3

data2:

key1 key2     R    S 0  K0   K0 R0 S0

  1. K1   K0 R1 S1
  2. K1   K0 R2 S2
  3. K2   K0 R3 S3
  • Write a Pandas program to join two dataframes using keys from right dataframe only.

Test Data:

data1:

key1 key2     P    Q 0  K0   K0 P0 Q0

  1. K0   K1 P1 Q1
  2. K1   K0 P2 Q2
  3. K2   K1 P3 Q3
data2: 
key1key2RS
0   K0K0R0S0
1   K1K0R1S1
2   K1K0R2S2
3   K2K0R3S3
  1. Write a Pandas program to merge two given datasets using multiple join keys.

Test Data:

data1:

key1 key2     P    Q 0  K0   K0 P0 Q0

  1. K0   K1 P1 Q1
  2. K1   K0 P2 Q2
  3. K2   K1 P3 Q3

data2:

key1 key2     R    S 0  K0   K0 R0 S0

  1. K1   K0 R1 S1
  2. K1   K0 R2 S2
  3. K2   K0 R3 S3
  1. Write a Pandas program to create a new DataFrame based on existing series, using specified argument and override the existing columns names.
  1. Write a Pandas program to create a combination from two dataframes where a column id combination appears more than once in both dataframes.

Test Data:

data1:

key1 key2     P    Q 0  K0   K0 P0 Q0

  1. K0   K1 P1 Q1
  2. K1   K0 P2 Q2
  3. K2   K1 P3 Q3

data2:

key1 key2     R    S 0  K0   K0 R0 S0

  1. K1   K0 R1 S1
  2. K1   K0 R2 S2
  3. K2   K0 R3 S3
  1. Write a Pandas program to combine the columns of two potentially differently-indexed DataFrames into a single result DataFrame.

Test Data:

data1:

A    B

K0 A0 B0

K1 A1 B1

K2 A2 B2

data2:

C    D

K0 C0 D0

K2 C2 D2

K3 C3 D3

  1. Write a Pandas program to merge two given dataframes with different columns.

Test Data:

data1:

key1 key2     P    Q 0  K0   K0 P0 Q0

  1. K0   K1 P1 Q1
  2. K1   K0 P2 Q2
  3. K2   K1 P3 Q3

data2:

key1 key2     R    S 0  K0   K0 R0 S0

  1. K1   K0 R1 S1
  2. K1   K0 R2 S2
  3. K2   K0 R3 S3
  1. Write a Pandas program to Combine two DataFrame objects by filling null values in one DataFrame with non-null values from other DataFrame.

Test Data:

Original DataFrames: A B

0 NaN 3

1 0.0 4

2 NaN 5 A B

0 1 3.0

1 1 NaN

2 3 3.0

Powered by BetterDocs

Contact Us
close slider