[Solved] How can I extract a string from a text field that matches with a “value” in my Dictionary and return the dict’s key into a new column in the Output? [closed]

How can I extract a string from a text field that matches with a “value” in my Dictionary and return the dict’s key into a new column in the Output? [closed] solved How can I extract a string from a text field that matches with a “value” in my Dictionary and return the dict’s key … Read more

[Solved] Writing Specific CSV Rows to a Dataframe

I appreciate being downvoted without given reasons why my question deserves a downvote. I was able to figure it out on my own though. Hopefully, this may answer other people’s questions in the future. import csv import pandas as pd temp = [] #initialize array with open(‘C:/Users/sword/Anaconda3/envs/exceltest/RF_SubjP02_Free_STATIC_TR01.csv’, ‘r’) as csvfile: csvreader = csv.reader(csvfile, delimiter=”,”) for … Read more

[Solved] How to write this code without using pandas?

You can simply use the csv module from the standard library: import csv with open(‘__.csv’, ‘r’, newline=””) as f: reader = csv.reader(f) _ , *header = next(reader) d = {} for k, *row in reader: d[k] = dict(zip(header, row)) print(d) {‘reviews’: {‘JOURNAL_IMPACT_FACTOR’: 27.324, ‘IMPACT_FACTOR_LABEL’: ‘Highest’, ‘IMPACT_FACTOR_WEIGHT’: 37.62548387}, ‘hairdoos’: {‘JOURNAL_IMPACT_FACTOR’: 40.0, ‘IMPACT_FACTOR_LABEL’: ‘middle’, ‘IMPACT_FACTOR_WEIGHT’: 50.0}, ‘skidoos’: … Read more

[Solved] Columns and rows concatenation with a commun value in another column

You can use groupby and join to create the expected output. One way is to create a column to_join from the columns Tri_gram_sents and Value, and then agg this column: df[‘to_join’] = df[‘Tri_gram_sents’] + ‘ ‘ + df[‘Value’].astype(str) ser_output = df.groupby(‘sentence’)[‘to_join’].agg(‘ ‘.join) Or you can do everything in one line without create the column with … Read more

[Solved] Function should clean data to half the size, instead it enlarges it by an order of magnitude

When you merge your dataframes, you are doing a join on values that are not unique. When you are joining all these dataframes together, you are getting many matches. As you add more and more currencies you are getting something similar to a Cartesian product rather than a join. In the snippet below, I added … Read more

[Solved] How to split a list’s value into two lists [closed]

If you have it as datetimeobject: datos[‘day’] = dados[‘time’].dt.date datos[‘time’] = dados[‘time’].dt.time If you have it as string object: datos[‘day’] = dados[‘time’].str[:11] datos[‘time’] = dados[‘time’].str[11:] Or data[[‘day’, ‘time’]] = data[‘time’].str.split(‘ ‘).apply(pd.Series) data[[‘day’, ‘time’]] = data[‘time’].str.split(‘ ‘, expand=True) Or using regex data[[‘day’, ‘time’]] = data[‘time’].str.extract(‘(.*) (.*)’) To convert it to string: datos[‘time’] = dados[‘time’].astype(str) It is … Read more