Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this question: There's an error when I run this code, it tells me:IndexError: too many indices for array: array is 1-dimensional,

Please help me with this question:

There's an error when I run this code, it tells me:IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed.

How can I solve it? My code: import numpy as np data = np.genfromtxt('data_temperature.txt', delimiter=',', dtype=None, encoding=None, skip_header=1) #data = np.loadtxt('data_temperature.txt', delimiter=',', usecols =[0,1,2,3,4,5,6,7], skiprows = 1)

#Task 2 #Pre-Todos et todas-Avant tout: def filter_by_city(data, city_name): return data[data[:, 1] == city_name.encode()]

Btw, the data type is

Date,Location,Max Temperature (C),Min Temperature (C),Precipitation (mm),Wind Speed (km/h),Humidity (%),Cloud Cover (%)

2023-01-01,New York,5,-2,10,20,70,40

2023-01-02,New York,4,-3,8,18,75,30 for 10 cities

#Group Project #Task 1 import numpy as np data = np.genfromtxt('data_temperature.txt', delimiter=',', dtype=None, encoding=None, skip_header=1) #data = np.loadtxt('data_temperature.txt', delimiter=',', usecols =[0,1,2,3,4,5,6,7], skiprows = 1) #Task 2 #Pre-Todos et todas-Avant tout: def filter_by_city(data, city_name): return data[data[:, 1] == city_name.encode()] New_York_data = filter_by_city(data, 'New York') Los_Angeles_data = filter_by_city(data, 'Los Angeles') London_data = filter_by_city(data, 'London') Tokyo_data = filter_by_city(data, 'Tokyo') Beijing_data = filter_by_city(data, 'Beijing') Sydney_data = filter_by_city(data, 'Sydney') Paris_data = filter_by_city(data, 'Paris') Berlin_data = filter_by_city(data, 'Berlin') Cairo_data = filter_by_city(data, 'Cairo') New_Delhi_data = filter_by_city(data, 'New Delhi')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago