filmov
tv
Python Indices Can Really Be Used Like This??? #shorts #python #pythonprogramming #index #dataframe
Показать описание
This YouTube Shorts video explains how to insert a new row at a certain index position of a pandas DataFrame. We have to slice our data!!!
Python code of this video:
import pandas as pd # Load pandas library
my_data = pd.DataFrame({"x1":["a", "b", "c", "b"], # Create pandas DataFrame
"x2":range(16, 20),
"x3":range(1, 5),
"x4":["a", "b", "c", "d"]})
print(my_data) # Print pandas DataFrame
my_row = [11, 22, 33, 44] # Create list
print(my_row) # Print list
print(data_new) # Print updated DataFrame
drop = True)
print(data_new) # Print updated DataFrame
Follow me on Social Media:
Python code of this video:
import pandas as pd # Load pandas library
my_data = pd.DataFrame({"x1":["a", "b", "c", "b"], # Create pandas DataFrame
"x2":range(16, 20),
"x3":range(1, 5),
"x4":["a", "b", "c", "d"]})
print(my_data) # Print pandas DataFrame
my_row = [11, 22, 33, 44] # Create list
print(my_row) # Print list
print(data_new) # Print updated DataFrame
drop = True)
print(data_new) # Print updated DataFrame
Follow me on Social Media: