Math, asked by rishu4467, 10 months ago

Create a panda series that contains the first n natural numbers and their respective squares. The first n numbers should appear in the index position.

Answers

Answered by Shaizakincsem
0

Thank you for asking this question. Here is your answer:

import pandas as pd

import random

import string

k = 5

N = 10


print df

#    A   B  C

#0   1  60  O

#1   2  94  L

#2   3  10  W

#3   4  94  X

#4   5  60  O

#5   6  20  K

#6   7  58  Y

#7   8  40  I

#8   9  49  X

#9  10  65  S

If there is any confusion please leave a comment below.

Answered by PHEONIX001
3

TRY THIS:::

import numpy as np

import pandas as pd

n =int( input())

for i in n:

   a=pd.Series([i])

   b=pd.Series([i**2])

c=pd.Series(b,a)

print(c)

Similar questions