All Questions
Tagged with dataframe dictionary
2,760
questions
1
vote
2
answers
55
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 ...
0
votes
2
answers
52
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,
"...
1
vote
2
answers
48
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":[
...
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 ...
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(...
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 ...
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):
...
-1
votes
1
answer
53
views
Create a dataframe from a dictionary of lists (which contain a dictionary)
I have a dictionary:
data1 = {
'AI': [3, {'G': 0.0, 'C': 0.31666666666666665, 'L': 0.3333333333333333, 'U': 0.0, 'J': 0.0, 'W': 0.0, 'O1': 0.3333333333333333, 'O2': 0.016666666666666666, 'T1': 0.0,...
0
votes
1
answer
69
views
Unordered txt file contents: How to design in proper dictionary
I have txt file and it's contents are unordered like below sample. I must select first row because it has train run exact time.
my txt file has couple of summary 1, 2 and so on. hence, keys are same ...
0
votes
1
answer
19
views
resizing two arrays to be used in a DataFrame
I'm trying to create a pandas DataFrame from a dictionary. We know that to do so, all the dictionary elements must be of the same dimension. The dictionary is composed of two ndarrays; one with the ...
1
vote
1
answer
26
views
Spark: No implicits found for parameter evidence
I have the following Spark code on Scala:
def main(args: Array[String]): Unit = {
val spark = SparkSession.builder.master("local").getOrCreate()
import spark.implicits._
...
0
votes
0
answers
34
views
Adding a single column to each dataframe in a dictionary of dataframes
Ok so I have a dictionary of dataframes df_dict that looks like this
{'df ICU:1 ': ICU: 1
0 True
1 False
2 True
3 True
4 True
5 ...
2
votes
2
answers
51
views
Dyamically Update Column in Python DataFrame using substrings
Lets say I have a data frame lets call it A
Key_Word
Code
Market
A1
Theater
A2
And I have another Data Frame lets call it B
Sentence
Components_from_A
John went to the theater
Mary went to the ...
0
votes
2
answers
40
views
Filtering a python DataFrame based on whether two column values in each row are found within a dictionary
I have a df that contains a subject ID and an item ID. An item ID may appear multiple times for one subject ID and multiple item IDs may be assigned to one subject ID.
subid itemid
0 0001 1111
1 ...
0
votes
1
answer
54
views
How do I create a multi-indexed DataFrame from a double-nested dictionary?
I am trying to create a pandas multi-indexed DataFrame from a double-nested dictionary but am quite stumped as to how to do this.
As some background I have scraped some data from a website and put it ...