delimiter

Hierarchical string delimiting not splitting

Hierarchical string delimiting not splitting Question: I am trying to create a function to parse a string based on multiple delimiters, but in a hierarchical format: i.e., try the first delimiter, then the second, then the third, etc. This question seemingly provides a solution, specifically linking this comment. # Split the team names, with a …

Total answers: 3

splitting the address column in pandas

splitting the address column in pandas Question: I have a pandas dataset like this: import pandas as pd data = {‘id’: [‘001’, ‘002’, ‘003’,’004′], ‘address’: ["William J. Clare\n290 Valley Dr.\nCasper, WY 82604\nUSA", "1180 Shelard Tower\nMinneapolis, MN 55426\nUSA", "William N. Barnard\n145 S. Durbin\nCasper, WY 82601\nUSA", "215 S 11th ST"], ‘locality’: [None, None, None,’Laramie’], ‘region’: [None, None, …

Total answers: 2

How to convert a list with special delimiter to a python dataframe?

How to convert a list with special delimiter to a python dataframe? Question: I have the following list where double brackets indicate a new element: [[[33.79277702, -104.3900481], [35.79415582, -104.39016576], [38.7939, -107.31792], [31.792589, -188.38847], [36.79221, -108.388367], [36.79238003, -108.38905313]], [[38.1726905, -54.85042496], [30.179095, -84.88893], [36.17621409, -84.78], [39.17534035, -84.8481921], [31.17427369, -84.8499793], [50.17466907, -84.8578298]], [[46.71949073, -109.69390116], [46.72091429, -109.69484574], [46.72077, -107.69432], …

Total answers: 1

splitting a string with multiple delimiters doesn't work

splitting a string with multiple delimiters doesn't work Question: I’m trying to split a string suing multiple delimiters. Somehow it just doesn’t work, it only works if I use each delimiter separately. What am I doing wrong? string = ‘rnrn rnrnfirst_col: col1 rnrnsecond_col: col2 rnrnthird_col: col3 rnrnfourth_col: col4 rnrnfith_col: col5rn’ splitter = "rnrn | rnrn| …

Total answers: 1

How to split a filename based on the latest occurrence of repeated delimiters? (Python)

How to split a filename based on the latest occurrence of repeated delimiters? (Python) Question: How can I split a filename based on the latest occurrence of a repeated delimiter? Such that: Example File List: abc_123 abc_123_d4 abc__123 (2 underscores) abc_123__d4 (2 underscores) abc____123 (4 underscores) Expected Outcome: abc, 123 abc, 123, d4 abc_, 123 …

Total answers: 1

How to split on a delimiter in python preserving the delimiter

How to split on a delimiter in python preserving the delimiter Question: so what i wanna do here is basically i have a file with a list of url endpoints, and i wanna split the links in the file on the slash delimter, basically generating sub-endpoints of endpoints, example: https://www.somesite.com/path1/path2/path3 and i would want to …

Total answers: 3

Split element in list while keeping delimiter

Split element in list while keeping delimiter Question: I have a list that I want to split up a bit more, but the output for the data is such that I can’t keep it in a good format. Below is an example of what I’m doing data = [‘x’, ’10[mm]’, ‘y’, ’15[mm]’] Data = [data.split(‘[‘) …

Total answers: 4

Auto-detect the delimiter in a CSV file using pd.read_csv

Auto-detect the delimiter in a CSV file using pd.read_csv Question: Is there a way for read_csv to auto-detect the delimiter? numpy’s genfromtxt does this. My files have data with single space, double space and a tab as delimiters. genfromtxt() solves it, but is slower than pandas’ read_csv. Any ideas? Asked By: SEU || Source Answers: …

Total answers: 3

Convert commas decimal separators to dots within a Dataframe

Convert commas decimal separators to dots within a Dataframe Question: I am importing a CSV file like the one below, using pandas.read_csv: df = pd.read_csv(Input, delimiter=”;”) Example of CSV file: 10;01.02.2015 16:58;01.02.2015 16:58;-0.59;0.1;-4.39;NotApplicable;0.79;0.2 11;01.02.2015 16:58;01.02.2015 16:58;-0.57;0.2;-2.87;NotApplicable;0.79;0.21 The problem is that when I later on in my code try to use these values I get this …

Total answers: 5