Skip to content

Tag: csv

Adding date to pd.to_datetime

I’m looking for a way to add custom date to pd.to_datetime. So, for example: Print: pd.to_datetime keeps adding today’s date which is fine in case of csv_file but csv_file2 need to contain tomorrow’s date. Here’s sample of csv files: Answer Idea is create helper column file for disting…

Python to remove extra delimiter

We have a 100MB pipe delimited file that has 5 column/4 delimiters each separated by a pipe. However there are few rows where the second column has an extra pipe. For these few rows total delimiter are 5. For example, in the below 4 rows, the 3rd is a problematic one as it has an extra pipe. Is there any

Function to read csv string

This question is duplicate of a now deleted earlier question now edited as per the comments provided in the original. I am trying to create a function which takes a string input in CSV format. For example “id,name,age,scoren1,Jack,NULL,12n17,Betty,28,11”. It should return the follow table: id name…

CSV data preprocess

I have a .csv file like this format Then I want to convert it to How can I do it with python pandas Thank you Answer If you load it then you will have DataFrame like Set multi-index usinig year and month Reshape it using stack() You can add name to column with day Reset index to get normal columns