Nov-26-2022, 02:26 PM
i guess it's okay, but still,
here's the code:
as you can see there's an added column at the beginning (the most left) of digits (signifying the row number),
isn't the row number already taken into account ? (or is it just in Excel where it gives the rows their numbers ?)
so if a column is added to signify the row's numbers (like an index) i have no problem, but suppose i delete an additional time a column that was not deleted in the first deletion, what happens is it adds another column (the rows index twice),
here's the code:
import pandas as pd data = pd.read_csv('/home/tal/investing/allstocks.csv') print("Original 'allstocks.csv' CSV Data: \n") print(data) df = pd.DataFrame(data) df.drop(df.columns[3:], axis=1, inplace=True) df.to_csv('/home/tal/investing/allstocks.csv') print("\nCSV Data after deleting the column 'year':\n") print(df)and attached is a screenshot of the result,
as you can see there's an added column at the beginning (the most left) of digits (signifying the row number),
isn't the row number already taken into account ? (or is it just in Excel where it gives the rows their numbers ?)
so if a column is added to signify the row's numbers (like an index) i have no problem, but suppose i delete an additional time a column that was not deleted in the first deletion, what happens is it adds another column (the rows index twice),