+ 1

Creating a new dataframe based on range of column number given by user.

I want to make a script for data stacking where the user will tell the number of columns in range where the block of subset needs to be stacked. for e.g. user will pass: 6,14:20,23,28:10 I want to extract and create a new dataframe based on those location. I tried doing it with np_r method, also tried to pass it in iloc but both return ERROR. Is it possible to create a dataframe from another dataframe where the user gives the location of the input ? import pandas as pd import numpy as np path = input("Enter complete path of the dataset with forward slashes - / :") df = pd.read_excel(path) n = int(input("Enter the number of repeated block of values: ")) print("Location of the unique variables seperated by spaces (If range of values then write it as 1:3)") unique = input("Enter the location: ") unique = unique.split(' ') df.iloc[:, np.r_[unique]]

23rd Nov 2018, 11:54 AM
Siddiqui Mohd. Saif
Siddiqui Mohd. Saif - avatar
1 Odpowiedź
0
What exactly are you trying to do with that input? What is repeated block and unique block in here?
31st Dec 2018, 5:33 PM
Rugved Modak
Rugved Modak - avatar