To create an empty data frame and add new columns in it (prime number and its square)
import pandas as pd
df =pd.DataFrame()
print(df)
import pandas as pd
df =pd.DataFrame()
# Adding a column to an existing DataFrame
df['Rollno']=[1,2,3,4,5]
df['Name']=['Kunal','Ram','Sahil','Preeti','Raj']
print(df)
Rollno | Name | |
---|---|---|
0 | 1 | kunal |
1 | 2 | Ram |
2 | 3 | sahil |
3 | 4 | preeti |
4 | 5 | Raj |
Just click the next button to see which element goes to which position.
Name of Columns | |||
Row Index | 'One' | 'Two' | 'Three' |
0 | 1 | 2 | 3 |
1 | 4 | 5 | 6 |
2 | 7 | 8 | 9 |
The start of row 0
The element 1 of sub-list 1 is assigned to [ 0 , 0 ] in the DataFrame
The element 2 of sub-list 1 is assigned to [ 0 , 1 ] in the DataFrame
The element 3 of sub-list 2 is assigned to [ 0 , 2 ] in the DataFrame
The end of row 0
The start of row 1
The element 4 of sub-list 2 is assigned to [ 1 , 0 ] in the DataFrame
The element 5 of sub-list 2 is assigned to [ 1 , 1 ] in the DataFrame
The element 6 of sub-list 3 is assigned to [ 1 , 2 ] in the DataFrame
The end of row 1
The start of row 2
The element 7 of sub-list 3 is assigned to [ 2 , 0 ] in the DataFrame
The element 8 of sub-list 3 is assigned to [ 2 , 1 ] in the DataFrame
The element 9 of sub-list 4 is assigned to [ 2 , 2 ] in the DataFrame
The end of row 2
The end of row 3
import pandas as pd
Df = pd.DataFrame()
Df["Numbers"] = np.arange(3)
Df["Square"] = Df["Numbers"]*Df["Numbers"]
print(Df)
Number | Square | |
---|---|---|
0 | 1 | 1 |
1 | 2 | 4 |
2 | 3 | 9 |
Number | Square | |
---|---|---|
0 | 1 | 1 |
1 | 2 | 4 |
2 | 3 | 9 |
Square | Number | |
---|---|---|
0 | 1 | 1 |
1 | 2 | 4 |
2 | 3 | 9 |
Mr. Vivek Sharma, B.Sc Physical Sciences with Computer Science, II year,
Ms. Palak Sharma, B.Sc Physical Sciences with Computer Science, II year
Mentors:
Prof. Sharanjit Kaur,
Ms. Gunjan Rani