I’m a noob trying to learn Python by scraping a website to track fund parameters. So far, the following code isolates and shows the data that I need, This code shows the following data: How can I write this data to a CSV with the following headers? This is for a single fund and I need to get this data
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
Python Pandas drop_duplicates – adds a new column and row to my data frame
I read a csv file and I want to remove duplicate entries. When I run the commands to do that, it creates a new first row that contains column numbers and a new column that contains row numbers. See Why does it do that and how should I fix this? Answer Use df.to_csv(file, header=False, index=False) to save the…
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
how can get difference between a defined date and the dates from a csv file python
I have a list of dates and I want to get a difference from a defined one(I mean days) and append days calculated in a new column I get TypeError: unsupported operand type(s) for -: ‘DatetimeArray’ and ‘datetime.date’ Now how can I read the dates in csv file in the same format as the de…
Get line count of a specific column and get the value of that specific column using row number [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question python, pandas read from csv file. How do I get only TMI value from a specific row? I mean by…
What is wrong my python code, I’m trying to add implement multiple file search criteria for files
I want to make changes in my code so I can search for multiple input files and type multiple inputs, let’s say if client order number 7896547 exist in the input file I put there. What is the best way to implement multiple search criteria for multiple files. What I meant is giving around let’s say …
Transform matrix adjacency to Source, Target, Value in CSV file (python)
I have this CSV file, with adjacency matrix: I want to transform to a new csv file, with the values of sorce, target, and value. For example: Thanks! Answer If you replace the zeros with nan, you can use stack to achieve this. Output