How can I split a dataframe
import pandas as pd
import numpy as np
np.random.seed(0)
df = pd.DataFrame({'first':np.random.rand(4),'second':np.random.rand(4)},index=['foo','bar','baz','bat'])
print(df)
first second
foo 0.548814 0.423655
bar 0.715189 0.645894
baz 0.602763 0.437587
bat 0.544883 0.891773
into the two following disjoint data frames
first second
foo 0.548814 0.423655
bar 0.715189 0.645894
first second
baz 0.602763 0.437587
bat 0.544883 0.891773
by using the indices for the first data frame?
I am specifically looking for a method like
subDf1,subDf2 = pd.split(df,['foo','bar'])
where
print(subDf1)
first second
foo 0.548814 0.423655
bar 0.715189 0.645894
and
print(subDf2 )
first second
baz 0.602763 0.437587
bat 0.544883 0.891773