All Questions
1,260 questions
0
votes
2
answers
105
views
How to update Pandas DataFrame column using string concatenation in function
I have a dataframe where I would like to add a full address column, which would be the combination of 4 other columns (street, city, county, postalcode) from that dataframe. Example output of the ...
0
votes
2
answers
87
views
Count number of characters in each row and drop if all are below a certain number
I have a dataframe with many columns, all of which contain text data mixed with NaNs.
I want to count the number of characters in each cell in each column and then drop any rows where all the columns ...
0
votes
2
answers
60
views
Expand a dataframe row into multiple rows based on string conditions
I have some raw data similar to the dataframe below:
df = pd.DataFrame([{'var1': '220-224 (Even) roadname1', 'var2': 'location 1', 'var3': 'area 1'},
{'var1': 'site of 5 to 9 (odd) ...
1
vote
3
answers
72
views
How to find integer index of a string in a column in pandas dataframe?
I am importing a csv file in pandas containing data like this. Referring to following code, I want to get integer index of row containing name_to_search in column name in df1.
name, ColB, ColC, ColD
...
3
votes
2
answers
560
views
Polars Lazy DataFrame is hung up on Df.collect()
To preface, I am learning the language of python, as well as polars.
I am working with individual contribution data from citizens to political candidates between the years of 2010 to 2022. My data ...
0
votes
4
answers
74
views
How do I extract substrings of a dataframe column by referencing another column?
Let's say I have a dataframe as below:
import pandas as pd
nhl_df = pd.DataFrame({
"team": ["Tampa Bay Lightning", "Boston Bruins", "Toronto Maple Leafs",
...
0
votes
2
answers
162
views
How to fix column with numeric values that is taken as a string field because of empty strings in Pandas dataframe?
I have a df with some columns that are supposed to be numeric fields. However, there are empty strings existing in these columns, which leads to their data being incorrectly assigned as 'object'. How ...
0
votes
1
answer
51
views
Convert range of numbers to average in a pandas dataframe cell
I have a pandas dataframe read from large spreadsheets provided through a survey. In a column that expects float input, some of the cell entries are expressed as "n1-n2" (where n1 and n2 are ...
0
votes
1
answer
36
views
map one column value to another column in python dataframe
I have a dataframe with below columns in it -
id|title|
23|xyz|
34|kij|
123|hyu|
45|NaN|
345|None|
I want new column in it , expected output -
id|title|url
23|xyz|https://www.cl.com/23/xyz
34|kij|...
0
votes
0
answers
85
views
How do I get the list of the longest common substrings with a minimum length in a Pandas DataFrame column of strings that is over 10000 entries?
So I have a pandas DataFrame where there are over 50000 rows. In one column, there is a list of strings that has no spaces, and is converted to lowercase, and there are multiple junk characters. The ...
1
vote
3
answers
67
views
Concatenating row, column indexes from a dataframe
I have one dataframe like this with the first column is the index (i.e., index = [1,2,3]):
1 2 3
1 0 0.43 0.61
2 0.88 0 0.12
3 0.33 0.95 0
The new dataframe ...
0
votes
6
answers
65
views
Extract substring between a : and a string of a predefined set of strings
I have the following input as a a column of a df, each row is one string:
surname: Chardon firstname: Marie occupation: idem link: fille age: 30
surname: Lhopital firstname: Louis-Jean occupation: sp ...
0
votes
2
answers
100
views
Could not convert string to float: '5,994.98'
You can see here the desired output
Desired Output
Code if you want see = https://github.com/LLNL/mttime/blob/master/examples/notebooks/02_Prepare_Data_and_Synthetics_For_Inversion.ipynb
Error in ...
-1
votes
2
answers
54
views
Extract multiple values from a string at once
I'm trying to clean up my data in strings in this format:
'Ti': ['88.115', '199.2', '44.4', '39.0', '1.89', '89', '0.870']
I want to extract values [0], values [1] and values [-2]. Doing this manually ...
0
votes
3
answers
69
views
Find a Specific String Value and Change by A Different One
I have a dataframe
category_groups_list
Count
Health Care
10
Financial Services,Lending and Investments
15
Real Estate
5
Financial Services
20
Financial Services,Professional Services
25
Financial ...