title: Get the original train-test split based on an integer column value after using pd.get_dummies
body: <p>I combined my train and test dataset and used get_dummies function from pandas to one hot encode categorical data. The reason behind concatenating was the number of levels in categorical data for train and test set were different.</p>
  
  <p>If I use the get_dummies function on separate train and test set then I would get a dataframe of different dimension as out so I thought of combining them.</p>
  
  <p>I want to now again split it into train and test set. Is it possible?</p>
  
  <p>Assume that the output we get after using pd.get_dummies is named as 'dataset'. If the value of 'C10' column in dataset is 30(integer) then the data beleongs to test set otherwise it belongs to trainset.</p>
  
  <p>If I try to select values like we do in a normal dataframe I get the following error:</p>
  
  <pre><code>dataset = pd.concat([train, test])
  dataset_dummy = pd.get_dummies(dataset, prefix_sep='_', columns = cat_columns, sparse = True, drop_first = True)
  
  test_dummy = dataset_dummy.iloc[dataset_dummy['day'] == 30]
  
  
  AttributeError: 'BlockManager' object has no attribute 'T'
  </code></pre>