pandas

compare 2 columns in different dataframes

徘徊边缘 提交于 2021-02-11 14:09:36
问题 if I have 2 tables b ,c and I want to go for c and check column called parent if the value equal to the value of column PrentSKU in table b, then bring the value of column ChildSKU from table b and put it in column Style in table c, else do nothing I tried to use compare methods but the table size is different so it gave me an error, and I also tried for loop but it also gave me an error that The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all(). The

Data frame column translation

删除回忆录丶 提交于 2021-02-11 14:08:02
问题 I need to translate a column in a dataframe from english to arabic the code runs fine but it don't translate the words instead it gives me this in the new column I am translating in Translated(src=en,dst=ar,text='the sentence in english) Here is the code I am using import pandas as pd file = pd.read_excel('HS_CODES_UNITS.xlsx') from googletrans import Translator translator = Translator() file['Product description in arabic'] = file['Product Description in English'].apply(translator.translate,

Data frame column translation

旧时模样 提交于 2021-02-11 14:07:32
问题 I need to translate a column in a dataframe from english to arabic the code runs fine but it don't translate the words instead it gives me this in the new column I am translating in Translated(src=en,dst=ar,text='the sentence in english) Here is the code I am using import pandas as pd file = pd.read_excel('HS_CODES_UNITS.xlsx') from googletrans import Translator translator = Translator() file['Product description in arabic'] = file['Product Description in English'].apply(translator.translate,

How to process the Time variables of OCO-2/Tropomi NETCDF4 files using Xarray?

非 Y 不嫁゛ 提交于 2021-02-11 14:02:41
问题 I am working on Tropomi .nc files. When I open the dataset using xarray, it does not process the time dimension. In Tropomi files, the time dimension is named as 'sounding_dim'. Instead of decoding the time, the returned output is just the sounding number. I have tried on OCO-2 .nc files as well. In OCO-2, the time dimension is 'sounding_id'. In case of OCO-2, the time is returned as a floating number, not as a date. The code and the output is given by: import numpy as np import xarray as xr

multiple merge operations on two dataframes using pandas

倖福魔咒の 提交于 2021-02-11 13:59:43
问题 I have two dataframes where multiple operations are to be implemented, for example: old_DF id col1 col2 col3 ------------------------- 1 aaa 2 bbb 123 new_DF id col1 col2 col3 ------------------------- 1 xxx 999 2 xxx kkk The following operations need to be performed on these dataframes: Merging the two dataframes Replacing only the blanks (NAs) cells in the old_DF with corresponding values from new_DF Cells from both the dataframes where the values are contradicting should be reported in a

How to test all possible combinations with True/False Statement in python?

柔情痞子 提交于 2021-02-11 13:58:51
问题 I have two DataFrames where each column contain True/False statements. I am looking for a way to test all possible combinations and find out where "True" for each row in df1 also is "True" in the corresponding row in df2. In reference to the data below, the logic would be something like this: For each row, starting in column "Main1", test if row is equal to True and if row in column "Sub1" also is True. Next, test if row in "Main1" is equal to true and if rows in column "Sub1" is True and

How can I make faceted plots in Plotly have their own individual YAxes tick labels?

独自空忆成欢 提交于 2021-02-11 13:58:28
问题 When I use Plotly express to plot different parameters with different ranges - in the example below, BloodPressureHigh, Height(cm), Weight(kg), and BloodPressureLow - using the facet_col argument, I am unable to get the resulting plot to display the unique YTicks for each of the faceted plots. Is there an easy method for the fig object to show each set of YTicks in the resulting faceted plot? Otherwise, as you can see in the resulting image, it is unclear that each box plot is on its own

multiple merge operations on two dataframes using pandas

自作多情 提交于 2021-02-11 13:58:25
问题 I have two dataframes where multiple operations are to be implemented, for example: old_DF id col1 col2 col3 ------------------------- 1 aaa 2 bbb 123 new_DF id col1 col2 col3 ------------------------- 1 xxx 999 2 xxx kkk The following operations need to be performed on these dataframes: Merging the two dataframes Replacing only the blanks (NAs) cells in the old_DF with corresponding values from new_DF Cells from both the dataframes where the values are contradicting should be reported in a

How can I make faceted plots in Plotly have their own individual YAxes tick labels?

痞子三分冷 提交于 2021-02-11 13:57:41
问题 When I use Plotly express to plot different parameters with different ranges - in the example below, BloodPressureHigh, Height(cm), Weight(kg), and BloodPressureLow - using the facet_col argument, I am unable to get the resulting plot to display the unique YTicks for each of the faceted plots. Is there an easy method for the fig object to show each set of YTicks in the resulting faceted plot? Otherwise, as you can see in the resulting image, it is unclear that each box plot is on its own

Aggregate DataFrame base on list values

最后都变了- 提交于 2021-02-11 13:55:08
问题 I have the next problem. I have a list with string values: a = ['word1', 'word2', 'word3', 'word4', ..., 'wordN'] And I have the dataframe with values: +--------------+----------+-----------+ | keywords | impressions | clicks | +--------------+----------+-----------+ | word1 | 1245523 | 12321231 | +--------------+----------+-----------+ | word2 | 4212321 | 12312312 | +--------------+----------+-----------+ ........................................ Please advice me on how to create a specific,