Here i don't understand how can i filter year and make every year data a new dataset from a single dataset. My Dataset is - Dataset
In this dataset, 2010 to 2020 (11 years) data is available.
And I need this dataset in this format- Output image. 2010 dataset
So My output should be look like this in format.
path = r"C:\Users\krishna gupta\Downloads\Diwali\temp"
files = os.listdir(path)
b=[]
for file in files:
df = pd.read_csv(path+'\\'+file)
df = df[df['SYMBOL'] == 'NIFTY']
df = df[df['INSTRUMENT'] == 'FUTIDX']
df['RANGE'] = df['HIGH'] - df['LOW']
df['YEAR'] = df.TIMESTAMP.str[-4:]
# df = (df.iloc[0])
# display(df)
b.append(df)
df = pd.concat(b)
df = df.sort_values(['YEAR','TIMESTAMP'])
df.reset_index(inplace=True)
del df['index']
df = df[df['YEAR'] == '2011']
df.head(5)
This is my code, And df = df[df['YEAR'] == '2011']
here I can filter data this way, but I want to print the data frame by itself.
And I'm really sorry in advance if I'm not writing my question in the right format because I'm new on StackOverflow. and thanks in advance.