Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
2 answers
54 views

Pandas Map Dictionary with Multiple Values to Dataframe

I have the following dataframe: data = [['BALANCED', 'Corp EUR'], ['YIELD', 'Corp USD'], ['GROWTH', 'HG CHF']] df = pd.DataFrame(data, columns=['STRATEGY', 'ASSET_CLASS'] df STRATEGY ...
Ben's user avatar
  • 173
0 votes
2 answers
50 views

Converting JSON list with multiple nested dictionaries to csv or excel

I have a JSON that I download from a website that has multiple nested dictionaries inside the main list. This is a very simplified version of it. [ { "id": 1, "...
TxHemi's user avatar
  • 9
1 vote
2 answers
45 views

Unpack values from column, which consist of list of dictionaries

I have dataframe, which looks like this: import pandas as pd df = pd.DataFrame({"item_id": [1, 2, 3], "item_properties":[ ...
Artem's user avatar
  • 11
2 votes
2 answers
56 views

find value in column, which contains list and take another value from next column and put it in first table to new column

I have two tables df1 = pd.DataFrame([{'a': 1}, {'a': 2}, {'a': 8}]) df1['b'] = "" df2 = pd.DataFrame([{'e': [1,2,3], 'f': 1},{'e': [4,5,6], 'f': 2},{'e': [7,8,9], 'f': 3}]) e f I ...
Joe Dhirk's user avatar
1 vote
1 answer
37 views

Can't access local dataframe from dictionary comprehension expression [duplicate]

I am using dictionary comprehension to compare each dataframe from within a dictionary to its corresponding dataframe in locals(). For some reason, I am getting a key error when accessing the locals()...
user2153235's user avatar
  • 1,052
-3 votes
0 answers
33 views

Counting OTPs by Sender, Missing first four OTPs from Senders(first) even if the sender has more than 5 Counts

import re, csv import pandas as pd class OTPAnalysis: def __init__(self) -> None: self.total_otp = [] self.count = 0 self.df = None self.sender_count = {} ...
vamshi's user avatar
  • 1
0 votes
1 answer
81 views

Why does converting a nested python dictionary into a pandas dataframe result in "has no attribute 'items' error?

I have a nested dictionary stored in the variable nested_dict_variable. The dictionary is retrieved by using SPSS valueLabels Property (Python) type(nested_dict_variable) results in dict. print(...
xChillout's user avatar
  • 105
1 vote
1 answer
54 views

Creating a column based on column values and dictionaries using vectorization in pandas

I have three columns in a pandas dataframe A, B, and C. I also have 3 dictionaries, dict_A, dict_B, dict_C that have all values of A, B, and C as keys in each respective dataframe. I am trying to ...
nickbagley's user avatar
0 votes
1 answer
36 views

Pandas Dataframe apply function multiple columns

product_code base_price promo_type q_bef q_aft 0 P11 190 50% OFF 34 52 1 P03 156 25% OFF 393 322 2 P07 300 ...
Sudha Rani Devarakonda's user avatar
1 vote
1 answer
46 views

Fill Column Values using a dictionary and pattern matching

I am working on categorizing credit card transaction. Right now I am using a dictionary combined with np.select() as follows: def cat_mapper(frame, targ_col, cat_col): ...
canconfirm24's user avatar
0 votes
0 answers
43 views

how to get list of values from nested panda dictionary and insert it in to a column [duplicate]

I have a nested dictionary which looks like following: {'NSE_FO:NIFTY28DEC21000CE': {'ohlc': None, 'depth': {'buy': [{'quantity': 0, 'price': 0.0, 'orders': 0}, {'quantity': 1, 'price': 3.0, '...
mona's user avatar
  • 91
0 votes
3 answers
65 views

CSV data format to nested dictionary

I have below csv format. I want it to convert some nested dict. name,columns,tests ABC_ESTIMATE_REFINED,cntquota,dbt_expectations.expect_column_to_exist ABC_ESTIMATE_REFINED,cntquota,not_null ...
snowflake_user's user avatar
1 vote
1 answer
77 views

How to get the values of a dictionary type from a parquet file using pyarrow?

I have a parquet file which I am reading with pyarrow. In [83]: pq.read_schema('dummy_file.parquet').field('dummy_column').type Out[83]: DictionaryType(dictionary<values=string, indices=int32, ...
In78's user avatar
  • 462
2 votes
4 answers
82 views

converting a dataframe to dictionary in python?

I have a dataframe like below: id|title|url|timed 2|xyz|www.xyz.com|2024-02-01T00:00:00Z| 3|ghy|NaN|2024-03-05T00:00:00Z| 4|None|NaN|2024-04-05T00:00:00Z| 56|ghy|www.ghy.com|2024-05-05T00:00:00Z| ...
emiley mille's user avatar
0 votes
1 answer
32 views

Convert a dataframe with lists to a dictionary [duplicate]

I have a dataframe that contains a identifier and list in each cell. The idea is to create a dictionary in which the keys are the identifiers and the values are a list with the elements that appears ...
Fernando Quintino's user avatar

15 30 50 per page
1
2 3 4 5
322