I want to extract only the data from Excel in Excel by specifying conditions.
Then I want to write the extracted data to Excel.
In the middle of that, I was trying to create a data frame with Pandas, and when I tried to change the data to Excel and assign a column name in the data frame definition part, the following error message occurred. It is written in the part of # that i am trying to do, but please also see if the code matches it.
Applicable source code
The truth value of a Series is ambiguous.Use a.empty, a.bool (), a.item (), a.any () or a.all ().
import pandas as pd df_A = pd.read_excel ("pandas_practice.xlsx", sheet_name = "Sheet1", index_col = [0,1]) # pd.read_excel (EXCEL file name, sheet_name = sheet name, index_col = column name/column number specified for index) Columns1 = ["CogDeg", "i", "j", "L", "B", "V"] #Column name df_B = pd.DataFrame (data = df_A, columns = Columns1) #Create a data frame with a named column df_C = df_B [df_B ["i"] == 0 and df_B ["j"] == 0] # Extract all rows where both column names i and j are 0 from the data frame df_C = pd.to_excel ("C: \ Desktop \ Python \ pandas_practice.xlsx", sheet_name = "Sheet2") # pd.to_excel (Destination directory + EXCEL file name, sheet_name = Sheet name)
I didn't understand even after examining it.Supplemental information (FW/tool version etc.)
Please provide more detailed information here.
Answer # 1
df_C = df_B [df_B ["i"] == 0 and df_B ["j"] == 0]
part is incorrect.
df_C = df_B [(df_B ["i"] == 0)&(df_B ["j"] == 0)]
[Python] Dealing with errors when multiple conditions are specified in pandas.DataFrame-Qiita
What to do when an error like The truth value of ... is ambiguous. occurs in numpy or pandas-A quiet name (拙 Article)
Answer # 2
☓ df_C = pd.to_excel (.. ....
◯ df_C.to_excel (......
- python - writing data to continuous excel using a text box
- extract only the necessary data from excel data with python and create another sheet
- python - i want to extract only the columns that satisfy the conditions with pytorch
- i want to input an element and extract one element using the python3 library openpyxl
- about the operation of excel using python
- i want to calculate multiple centroids using python and opencv
- python - recommended way to extract text from images
- i want to display an image using opencv from python
- i want to read an image file with python using pillow
- c # - i set an excel value using npoi, but it is not reflected in the reference
- image recognition using python beginner pyautogui is not possible
- i want to combine split images using cv2 (python)
- file reading and calculation using python
- i don't understand the description when using lambda for the key of the sort method of python
- i want to automatically create an excel quote with python
- to get the same output without using python dict
- [python/pandas] how to delete columns with 1 element at once
- python - i want to define a function using a csv file
- python3 extract and delete duplicate data of date and time
- [python] data preprocessing using pandas (deletion of multiple columns)
- python - i don't understand the indexing law of pandasseries i don't know how to take it out
- python - how to deal with error when converting pandas datetime type
- it seems that only the specified line from the large capacity csv is read into the data frame with pandas
- matplotlib - i want to draw a line graph of preprocessed data
- python 3x - how to combine the xth character to the yth character of the data read by pandas
- python 3x - i want to extract the top n columns for each "data frame" index
- replace even and odd numbers with symbols python
- i want to process sql data in python and create a graph (i made it, but it is heavy)
- python 3x - extract the data that meets the conditions from the data frame
- macos (osx) - sort_valus method error macos