Split Csv By Columns
I am trying to split a CSV file containing stock data of 1500+ companies. The first column contains dates and subsequent columns contain company data. Goal 1: I'm trying to split t
Solution 1:
a solution for goal1 is here. splitting CSV file by columns
However you have the pandas way:
import pandas as pd
# let's say first 10 columns
csv_path="mycsv.csv"
out_path ="\\...\\out.csv"pd.read_csv(csv_path).iloc[:, :10].to_csv(out_path)
You can also do something like
mydf.groupby("company_name").unstack()`
To make each company a column of its own
Post a Comment for "Split Csv By Columns"